delegation_manager.gno
Types
DelegationManager
DelegationManager manages the mapping between users and their delegation IDs. It provides efficient lookup and management of user delegations organized by delegator and delegatee addresses.
Methods
AddDelegationID
AddDelegationID appends a delegation ID to the delegator-delegatee pair, skipping duplicates. The whole get-modify-set runs inside this domain method so the nested BPTree mutation never escapes the owning realm. Performing the lookup in one realm and the write in another (e.g. re-fetching the inner tree across a realm boundary and mutating it) would hit the cross-realm write guard for the persisted leaf slot.
Parameters
delegator
string
delegator address string used to select the nested tree.
delegatee
string
delegatee address string used as the nested-tree key.
delegationID
int64
delegation ID to append when it is not already present.
GetDelegationIDs
GetDelegationIDs returns IDs recorded for one delegator/delegatee pair.
Parameters
delegator
string
delegator address string used to select the nested tree.
delegatee
string
delegatee address string used as the nested-tree key.
Return Values
[]int64
[]int64
delegation IDs stored for the pair.
bool
bool
true when the pair exists with a valid ID slice.
GetDelegatorDelegations
GetDelegatorDelegations returns the delegatee tree for one delegator.
Parameters
delegator
string
delegator address string used as the root-tree key.
Return Values
*bptree.BPTree
*bptree.BPTree
delegatee-to-delegation-ID tree when present and correctly typed.
bool
bool
true when the delegator entry exists with the expected tree type.
GetUserDelegations
GetUserDelegations returns the entire user delegations tree.
Return Values
*bptree.BPTree
*bptree.BPTree
tree keyed by delegator address string.
RemoveDelegationID
RemoveDelegationID removes a delegation ID from the delegator-delegatee pair. Like AddDelegationID, the read-modify-write is kept inside this domain method. RemoveDelegationID removes one ID from a delegator/delegatee pair. Missing pairs and IDs are left unchanged.
Parameters
delegator
string
delegator address string used to select the nested tree.
delegatee
string
delegatee address string used as the nested-tree key.
delegationID
int64
delegation ID to remove when it is present.
SetDelegationIDs
SetDelegationIDs stores the complete ID slice for a delegator/delegatee pair. A missing delegator entry is initialized with a new nested tree.
Parameters
delegator
string
delegator address string used to select or create the nested tree.
delegatee
string
delegatee address string used as the nested-tree key.
ids
[]int64
delegation IDs to store for the pair.
SetUserDelegations
SetUserDelegations replaces the root delegator-to-delegations tree.
Parameters
userDelegations
*bptree.BPTree
tree keyed by delegator address string and containing delegatee trees.
Constructors
func NewDelegationManager() *DelegationManager(source)
Last updated