apply requests
This commit is contained in:
parent
91767fc6d3
commit
88a11ec0bb
|
@ -3,7 +3,6 @@ package lib
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
wire "github.com/cosmos/cosmos-sdk/wire"
|
wire "github.com/cosmos/cosmos-sdk/wire"
|
||||||
|
@ -25,24 +24,27 @@ type ListMapper interface {
|
||||||
|
|
||||||
Get(sdk.Context, uint64, interface{}) error
|
Get(sdk.Context, uint64, interface{}) error
|
||||||
|
|
||||||
// Setting element out of range is harmful
|
// Setting element out of range will break length counting
|
||||||
// Use Push() instead of Set() to append a new element
|
// Use Push() instead of Set() to append a new element
|
||||||
Set(sdk.Context, uint64, interface{})
|
Set(sdk.Context, uint64, interface{})
|
||||||
|
|
||||||
|
// Other elements' indices are preserved after deletion
|
||||||
Delete(sdk.Context, uint64)
|
Delete(sdk.Context, uint64)
|
||||||
|
|
||||||
Push(sdk.Context, interface{})
|
Push(sdk.Context, interface{})
|
||||||
|
|
||||||
// Getter/Setter for meta information - can be customized
|
// Getter/Setter for meta information - can be customized
|
||||||
|
// Use this space for storing relevant information about the list
|
||||||
GetMeta(sdk.Context, interface{}) error
|
GetMeta(sdk.Context, interface{}) error
|
||||||
SetMeta(sdk.Context, interface{})
|
SetMeta(sdk.Context, interface{})
|
||||||
|
|
||||||
// Iterate*() is used to iterate over all existing elements in the list
|
// Iterate*() is used to iterate over all existing elements in the list
|
||||||
// Return true in the continuation to break
|
// Return true in the continuation to break
|
||||||
|
|
||||||
// CONTRACT: No writes may happen within a domain while an iterator exists over it.
|
// CONTRACT: No writes may happen within a domain while iterating over it.
|
||||||
IterateRead(sdk.Context, interface{}, func(sdk.Context, uint64) bool)
|
IterateRead(sdk.Context, interface{}, func(sdk.Context, uint64) bool)
|
||||||
|
|
||||||
|
// CONTRACT: No deletion may happend whihin a domain while iterating over it.
|
||||||
// IterateWrite() is safe to write over the domain
|
// IterateWrite() is safe to write over the domain
|
||||||
IterateWrite(sdk.Context, interface{}, func(sdk.Context, uint64) bool)
|
IterateWrite(sdk.Context, interface{}, func(sdk.Context, uint64) bool)
|
||||||
|
|
||||||
|
@ -134,8 +136,8 @@ func (lm GenericMapper) IterateRead(ctx sdk.Context, ptr interface{}, fn func(sd
|
||||||
if err := lm.cdc.UnmarshalBinary(v, ptr); err != nil {
|
if err := lm.cdc.UnmarshalBinary(v, ptr); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
s := strings.Split(string(iter.Key()), "/")
|
s := string(iter.Key()[len(lm.prefix)+6:])
|
||||||
index, err := strconv.ParseUint(s[len(s)-1], 10, 64)
|
index, err := strconv.ParseUint(s, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -182,10 +184,12 @@ type QueueMapper interface {
|
||||||
Peek(sdk.Context, interface{}) error
|
Peek(sdk.Context, interface{}) error
|
||||||
Pop(sdk.Context)
|
Pop(sdk.Context)
|
||||||
IsEmpty(sdk.Context) bool
|
IsEmpty(sdk.Context) bool
|
||||||
// Iterate() removes elements it processed
|
|
||||||
|
// Flush() removes elements it processed
|
||||||
// Return true in the continuation to break
|
// Return true in the continuation to break
|
||||||
// The interface{} is unmarshalled before the continuation is called
|
// The interface{} is unmarshalled before the continuation is called
|
||||||
// Starts from the top(head) of the queue
|
// Starts from the top(head) of the queue
|
||||||
|
// CONTRACT: Pop() or Push() should not be performed while flushing
|
||||||
Flush(sdk.Context, interface{}, func(sdk.Context) bool)
|
Flush(sdk.Context, interface{}, func(sdk.Context) bool)
|
||||||
|
|
||||||
// Key for the index of top element
|
// Key for the index of top element
|
||||||
|
|
Loading…
Reference in New Issue