-
Notifications
You must be signed in to change notification settings - Fork 1
/
agent.go
34 lines (25 loc) · 906 Bytes
/
agent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package keeper
import (
"github.com/celinium-network/celinium/x/restaking/multistaking/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func (k Keeper) GetExpectedDelegationAmount(ctx sdk.Context, coin sdk.Coin) (sdk.Coin, error) {
defaultBondDenom := k.stakingkeeper.BondDenom(ctx)
return k.EquivalentCoinCalculator(ctx, coin, defaultBondDenom)
}
func (k Keeper) GetAllAgentsByVal(ctx sdk.Context, valAddr sdk.ValAddress) []types.MultiStakingAgent {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.MultiStakingAgentPrefix)
defer iterator.Close()
valAddrStr := valAddr.String()
var agents []types.MultiStakingAgent
for ; iterator.Valid(); iterator.Next() {
var agent types.MultiStakingAgent
k.cdc.Unmarshal(iterator.Value(), &agent)
if agent.ValidatorAddress != valAddrStr {
continue
}
agents = append(agents, agent)
}
return agents
}