/
queue.go
36 lines (26 loc) · 1.18 KB
/
queue.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
// Keeper queue to manage calls.
package multisig
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/WingsDao/wings-blockchain/x/multisig/types"
)
// Adding a new call to queue.
func (keeper Keeper) addCallToQueue(ctx sdk.Context, callId uint64, height int64) {
store := ctx.KVStore(keeper.storeKey)
store.Set(types.GetQueueKey(callId, height), keeper.cdc.MustMarshalBinaryLengthPrefixed(callId))
}
// Remove a call from queue.
func (keeper Keeper) removeCallFromQueue(ctx sdk.Context, callId uint64, height int64) {
store := ctx.KVStore(keeper.storeKey)
store.Delete(types.GetQueueKey(callId, height))
}
// Getting queue iterator from block height to end block height.
func (keeper Keeper) GetQueueIteratorStartEnd(ctx sdk.Context, startHeight, endHeight int64) sdk.Iterator {
store := ctx.KVStore(keeper.storeKey)
return store.Iterator(types.GetPrefixQueue(startHeight), sdk.PrefixEndBytes(types.GetPrefixQueue(endHeight)))
}
// Get queue iterator till.
func (keeper Keeper) GetQueueIteratorTill(ctx sdk.Context, endHeight int64) sdk.Iterator {
store := ctx.KVStore(keeper.storeKey)
return store.Iterator(types.PrefixQueue, sdk.PrefixEndBytes(types.GetPrefixQueue(endHeight)))
}