Documentation ¶
Overview ¶
nolint
Index ¶
- func ErrNotASubTransaction() errors.TMError
- func IsNotASubTransactionErr(err error) bool
- func MakeBKey(key []byte) []byte
- func QueueHeadKey() []byte
- func QueueItemKey(i int64) []byte
- func QueueTailKey() []byte
- func SetKey() []byte
- type Bonsai
- func (b *Bonsai) Checkpoint() SimpleDB
- func (b *Bonsai) Commit(sub SimpleDB) error
- func (b *Bonsai) Discard()
- func (b *Bonsai) First(start, end []byte) Model
- func (b *Bonsai) Get(key []byte) []byte
- func (b *Bonsai) GetVersionedWithProof(key []byte, version int64) ([]byte, iavl.KeyProof, error)
- func (b *Bonsai) GetWithProof(key []byte) ([]byte, iavl.KeyProof, error)
- func (b *Bonsai) Has(key []byte) bool
- func (b *Bonsai) Last(start, end []byte) Model
- func (b *Bonsai) List(start, end []byte, limit int) []Model
- func (b *Bonsai) Remove(key []byte) (value []byte)
- func (b *Bonsai) Set(key, value []byte)
- func (b *Bonsai) String() string
- type ChainState
- type KVStore
- type KeyList
- type MemKVCache
- func (c *MemKVCache) Checkpoint() SimpleDB
- func (c *MemKVCache) Commit(sub SimpleDB) error
- func (c *MemKVCache) Discard()
- func (c *MemKVCache) First(start, end []byte) Model
- func (c *MemKVCache) Get(key []byte) (value []byte)
- func (c *MemKVCache) Has(key []byte) bool
- func (c *MemKVCache) Last(start, end []byte) Model
- func (c *MemKVCache) List(start, end []byte, limit int) []Model
- func (c *MemKVCache) Remove(key []byte) (value []byte)
- func (c *MemKVCache) Set(key []byte, value []byte)
- type MemKVStore
- func (m *MemKVStore) Checkpoint() SimpleDB
- func (m *MemKVStore) Commit(sub SimpleDB) error
- func (m *MemKVStore) Discard()
- func (m *MemKVStore) First(start, end []byte) Model
- func (m *MemKVStore) Get(key []byte) (value []byte)
- func (m *MemKVStore) Has(key []byte) (has bool)
- func (m *MemKVStore) Last(start, end []byte) Model
- func (m *MemKVStore) List(start, end []byte, limit int) []Model
- func (m *MemKVStore) Remove(key []byte) (value []byte)
- func (m *MemKVStore) Set(key []byte, value []byte)
- type Model
- type Queue
- type Set
- type SimpleDB
- type Span
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrNotASubTransaction ¶ added in v0.7.0
func IsNotASubTransactionErr ¶ added in v0.7.0
func QueueHeadKey ¶ added in v0.7.0
func QueueHeadKey() []byte
QueueHeadKey gives us the key for the height at head of the queue
func QueueItemKey ¶ added in v0.7.0
QueueItemKey gives us the key to look up one item by sequence
func QueueTailKey ¶ added in v0.7.0
func QueueTailKey() []byte
QueueTailKey gives us the key for the height at tail of the queue
Types ¶
type Bonsai ¶ added in v0.7.0
type Bonsai struct { Tree *iavl.VersionedTree // contains filtered or unexported fields }
Bonsai is a deformed tree forced to fit in a small pot
func NewBonsai ¶ added in v0.7.0
func NewBonsai(tree *iavl.VersionedTree) *Bonsai
NewBonsai wraps a merkle tree and tags it to track children
func (*Bonsai) Checkpoint ¶ added in v0.7.0
func (*Bonsai) Discard ¶ added in v0.7.0
func (b *Bonsai) Discard()
Discard will remove reference to this
func (*Bonsai) GetVersionedWithProof ¶ added in v0.7.0
func (*Bonsai) GetWithProof ¶ added in v0.7.0
type ChainState ¶ added in v0.7.0
type ChainState struct {
// contains filtered or unexported fields
}
ChainState maintains general information for the chain
func NewChainState ¶ added in v0.7.0
func NewChainState() *ChainState
NewChainState creates a blank state
func (*ChainState) GetChainID ¶ added in v0.7.0
func (s *ChainState) GetChainID(store KVStore) string
GetChainID gets the chain id from the cache or the store
func (*ChainState) SetChainID ¶ added in v0.7.0
func (s *ChainState) SetChainID(store KVStore, chainID string)
SetChainID stores the chain id in the store
type KeyList ¶ added in v0.7.0
type KeyList [][]byte
KeyList is a sortable list of byte slices
type MemKVCache ¶ added in v0.7.0
type MemKVCache struct {
// contains filtered or unexported fields
}
MemKVCache is designed to wrap MemKVStore as a cache
func NewMemKVCache ¶ added in v0.7.0
func NewMemKVCache(store SimpleDB) *MemKVCache
NewMemKVCache wraps a cache around MemKVStore
You probably don't want to use directly, but rather via MemKVCache.Checkpoint()
func (*MemKVCache) Checkpoint ¶ added in v0.7.0
func (c *MemKVCache) Checkpoint() SimpleDB
Checkpoint returns the same state, but where writes are buffered and don't affect the parent
func (*MemKVCache) Commit ¶ added in v0.7.0
func (c *MemKVCache) Commit(sub SimpleDB) error
Commit will take all changes from the checkpoint and write them to the parent. Returns an error if this is not a child of this one
func (*MemKVCache) Discard ¶ added in v0.7.0
func (c *MemKVCache) Discard()
Discard will remove reference to this
func (*MemKVCache) First ¶ added in v0.7.0
func (c *MemKVCache) First(start, end []byte) Model
First is done with List, but could be much more efficient
func (*MemKVCache) Get ¶ added in v0.7.0
func (c *MemKVCache) Get(key []byte) (value []byte)
Get gets a key, fulfills KVStore interface
func (*MemKVCache) Has ¶ added in v0.7.0
func (c *MemKVCache) Has(key []byte) bool
Has checks existence of a key, fulfills KVStore interface
func (*MemKVCache) Last ¶ added in v0.7.0
func (c *MemKVCache) Last(start, end []byte) Model
Last is done with List, but could be much more efficient
func (*MemKVCache) List ¶ added in v0.7.0
func (c *MemKVCache) List(start, end []byte, limit int) []Model
List is also inefficiently implemented...
func (*MemKVCache) Remove ¶ added in v0.7.0
func (c *MemKVCache) Remove(key []byte) (value []byte)
Remove uses nil value as a flag to delete... not ideal but good enough for testing
func (*MemKVCache) Set ¶ added in v0.7.0
func (c *MemKVCache) Set(key []byte, value []byte)
Set sets a key, fulfills KVStore interface
type MemKVStore ¶ added in v0.7.0
type MemKVStore struct {
// contains filtered or unexported fields
}
MemKVStore is a simple implementation of SimpleDB. It is only intended for quick testing, not to be used in production or with large data stores.
func NewMemKVStore ¶ added in v0.7.0
func NewMemKVStore() *MemKVStore
NewMemKVStore initializes a MemKVStore
func (*MemKVStore) Checkpoint ¶ added in v0.7.0
func (m *MemKVStore) Checkpoint() SimpleDB
func (*MemKVStore) Commit ¶ added in v0.7.0
func (m *MemKVStore) Commit(sub SimpleDB) error
func (*MemKVStore) Discard ¶ added in v0.7.0
func (m *MemKVStore) Discard()
func (*MemKVStore) First ¶ added in v0.7.0
func (m *MemKVStore) First(start, end []byte) Model
First iterates through all keys to find the one that matches
func (*MemKVStore) Get ¶ added in v0.7.0
func (m *MemKVStore) Get(key []byte) (value []byte)
func (*MemKVStore) Has ¶ added in v0.7.0
func (m *MemKVStore) Has(key []byte) (has bool)
func (*MemKVStore) Last ¶ added in v0.7.0
func (m *MemKVStore) Last(start, end []byte) Model
func (*MemKVStore) List ¶ added in v0.7.0
func (m *MemKVStore) List(start, end []byte, limit int) []Model
func (*MemKVStore) Remove ¶ added in v0.7.0
func (m *MemKVStore) Remove(key []byte) (value []byte)
func (*MemKVStore) Set ¶ added in v0.7.0
func (m *MemKVStore) Set(key []byte, value []byte)
type Queue ¶ added in v0.7.0
type Queue struct {
// contains filtered or unexported fields
}
Queue allows us to fill up a range of the db, and grab from either end
func NewQueue ¶ added in v0.7.0
NewQueue will load or initialize a queue in this state-space
Generally, you will want to stack.PrefixStore() the space first
func (*Queue) Item ¶ added in v0.7.0
Item looks at any element in the queue, without modifying anything
func (*Queue) Push ¶ added in v0.7.0
Push adds an element to the tail of the queue and returns it's location
type Set ¶ added in v0.7.0
type Set struct {
// contains filtered or unexported fields
}
Set allows us to add arbitrary k-v pairs, check existence, as well as iterate through the set (always in key order)
If we had full access to the IAVL tree, this would be completely trivial and redundant
func (*Set) List ¶ added in v0.7.0
List returns all keys in the set It makes a copy, so we don't modify this in place
func (*Set) Remove ¶ added in v0.7.0
Remove deletes this key from the set (same as setting value = nil)
type SimpleDB ¶ added in v0.7.0
type SimpleDB interface { KVStore Has(key []byte) (has bool) Remove(key []byte) (value []byte) // returns old value if there was one // Start is inclusive, End is exclusive... // Thus List ([]byte{12, 13}, []byte{12, 14}) will return anything with // the prefix []byte{12, 13} List(start, end []byte, limit int) []Model First(start, end []byte) Model Last(start, end []byte) Model // Checkpoint returns the same state, but where writes // are buffered and don't affect the parent Checkpoint() SimpleDB // Commit will take all changes from the checkpoint and write // them to the parent. // Returns an error if this is not a child of this one Commit(SimpleDB) error // Discard will remove reference to this Discard() }
SimpleDB allows us to do some basic range queries on a db
type Span ¶ added in v0.7.0
type Span struct {
// contains filtered or unexported fields
}
Span holds a number of different keys in a large range and allows use to make some basic range queries, like highest between, lowest between... All items are added with an index
This becomes horribly inefficent as len(keys) => 1000+, but by then hopefully we have access to the iavl tree to do this well
TODO: doesn't handle deleting....
func (*Span) Bottom ¶ added in v0.7.0
Bottom returns the lowest element in the Span, along with its index
func (*Span) GTE ¶ added in v0.7.0
GTE returns the lowest element in the Span that is >= h, along with its index
func (*Span) LTE ¶ added in v0.7.0
LTE returns the highest element in the Span that is <= h, along with its index
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the app states, separating the commited state (for queries) from the working state (for CheckTx and AppendTx)
func NewState ¶
func NewState(tree *iavl.VersionedTree, historySize int64) *State
NewState wraps a versioned tree and maintains all needed states for the abci app
func (State) Append ¶ added in v0.7.0
Append gives us read-write access to the current working state (to be committed at EndBlock)
func (State) Check ¶ added in v0.7.0
Append gives us read-write access to the current scratch state (to be reset at EndBlock)
func (State) Committed ¶ added in v0.7.0
Committed gives us read-only access to the committed state(s), including historical queries
func (State) IsEmpty ¶ added in v0.8.0
IsEmpty is true is no data was ever in the tree (and signals it is unsafe to save)
func (State) LatestHash ¶ added in v0.7.0
LatestHash is the root hash of the last state we have committed
func (State) LatestHeight ¶ added in v0.7.0
LatestHeight is the last block height we have committed