-
Notifications
You must be signed in to change notification settings - Fork 0
/
payoutlock.go
41 lines (32 loc) · 1.09 KB
/
payoutlock.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
35
36
37
38
39
40
41
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/furya-network/furya/utils"
)
// SetPayoutLock sets a lock for the payout element
func (k Keeper) SetPayoutLock(ctx sdk.Context, uniqueLock string) {
store := k.getPayoutLockStore(ctx)
store.Set(utils.StrBytes(uniqueLock), []byte{1})
}
// removePayoutLock removes a lock from payout
func (k Keeper) removePayoutLock(ctx sdk.Context, uniqueLock string) {
store := k.getPayoutLockStore(ctx)
store.Delete(utils.StrBytes(uniqueLock))
}
// GetAllPayoutLock returns all payout locks used during genesis dump.
func (k Keeper) GetAllPayoutLock(ctx sdk.Context) (list [][]byte, err error) {
store := k.getPayoutLockStore(ctx)
iterator := sdk.KVStorePrefixIterator(store, []byte{})
defer func() {
err = iterator.Close()
}()
for ; iterator.Valid(); iterator.Next() {
list = append(list, iterator.Value())
}
return
}
// getPayoutLock checks if payout lock exists
func (k Keeper) payoutLockExists(ctx sdk.Context, uniqueLock string) bool {
store := k.getPayoutLockStore(ctx)
return store.Has(utils.StrBytes(uniqueLock))
}