delegation.gno
NewDelegationTree
func NewDelegationTree() *bptree.BPTreeNewDelegationTree creates an empty tree for delegatee-to-delegation-ID mappings.
Return Values
*bptree.BPTree
*bptree.BPTree
empty tree configured for delegation lookup entries.
NewUserDelegationTree
NewUserDelegationTree creates an empty tree for user delegation mappings.
Return Values
*bptree.BPTree
*bptree.BPTree
empty tree configured for user delegation entries.
Types
Delegation
Delegation represents a delegation between two addresses
Methods
AddWithdraw
AddWithdraw appends a withdrawal record to the delegation history.
Parameters
withdraw
DelegationWithdraw
withdrawal record to append, including its amount and unlock timing.
Clone
Clone returns a deep copy of the delegation and its withdrawal slice.
Return Values
*Delegation
*Delegation
copied delegation, or nil when the receiver is nil.
CollectedAmount
CollectedAmount returns the amount already collected from undelegation.
Return Values
int64
int64
token amount released from this delegation.
CreatedAt
CreatedAt returns the Unix timestamp recorded when the delegation was created.
Return Values
int64
int64
creation timestamp in Unix seconds.
DelegateFrom
DelegateFrom returns the address that supplied the delegated tokens.
Return Values
address
address
delegator address recorded on the delegation.
DelegateTo
DelegateTo returns the address receiving the delegated voting power.
Return Values
address
address
delegatee address recorded on the delegation.
ID
Basic getters ID returns the unique identifier of the delegation record.
Return Values
int64
int64
delegation identifier assigned at creation.
SetCollectedAmount
SetCollectedAmount replaces the amount already collected from this delegation.
Parameters
amount
int64
released token amount in the smallest token unit.
SetUnDelegateAmount
Setters SetUnDelegateAmount replaces the amount currently in undelegation lockup.
Parameters
amount
int64
token amount awaiting collection in the smallest token unit.
SetWithdraw
SetWithdraw replaces one withdrawal record at the supplied slice index.
Parameters
index
int
zero-based index of the withdrawal entry to replace.
withdraw
DelegationWithdraw
replacement withdrawal record.
SetWithdraws
SetWithdraws replaces the complete withdrawal history.
Parameters
withdraws
[]DelegationWithdraw
withdrawal records to store for this delegation.
TotalDelegatedAmount
Amount getters TotalDelegatedAmount returns the current amount still actively delegated.
Return Values
int64
int64
active delegated token amount in the smallest token unit.
UnDelegatedAmount
UnDelegatedAmount returns the amount moved into undelegation lockup.
Return Values
int64
int64
token amount awaiting collection after its lockup period.
Withdraws
Withdraws getters Withdraws returns the delegation's withdrawal records.
Return Values
[]DelegationWithdraw
[]DelegationWithdraw
withdrawal entries tracked for this delegation.
Constructors
func NewDelegation(id int64, delegateFrom address, delegateTo address, delegateAmount int64, createdHeight int64, createdAt int64) *Delegation(source)
DelegationType
DelegationType represents the type of delegation operation
Methods
IsDelegate
IsDelegate reports whether the operation type is DelegateType.
Return Values
bool
bool
true only when d represents a delegation operation.
IsUnDelegate
IsUnDelegate reports whether the operation type is UnDelegateType.
Return Values
bool
bool
true only when d represents an undelegation operation.
String
String returns the textual operation name represented by the delegation type.
Return Values
string
string
"DELEGATE", "UNDELEGATE", or the underlying value for another type.
Last updated