Documentation
¶
Overview ¶
maintain severa pools of a number of elements in key->value form
This maintains a LevelDB database split into a series of tables. Each table is defined by a prefix byte.
Index ¶
- Constants
- func Finalise()
- func Initialise(database string)
- type Batch
- type Element
- type FetchCursor
- type IndexedPool
- func (p *IndexedPool) Add(key []byte, value []byte) (bool, error)
- func (p *IndexedPool) Flush() error
- func (p *IndexedPool) Get(key []byte) ([]byte, error)
- func (p *IndexedPool) Recent(start *gnomon.Cursor, count int, ...) ([]interface{}, *gnomon.Cursor, error)
- func (p *IndexedPool) Remove(key []byte) error
- type Iterator
- type Pool
- func (p *Pool) Add(key []byte, value []byte)
- func (p *Pool) Flush()
- func (p *Pool) Get(key []byte) []byte
- func (p *Pool) Has(key []byte) bool
- func (p *Pool) Iterate(key []byte) *Iterator
- func (p *Pool) LastElement() (Element, bool)
- func (p *Pool) NewFetchCursor() *FetchCursor
- func (p *Pool) Remove(key []byte)
Constants ¶
const ( // networking pools Peers = nameb('P') RPCs = nameb('R') Certificates = nameb('C') // transaction data pools TransactionData = nameb('T') TransactionState = nameb('S') // transaction index pools PendingIndex = nameb('U') VerifiedIndex = nameb('V') // asset AssetData = nameb('I') // ownership indexes OwnerCount = nameb('N') Ownership = nameb('K') OwnerDigest = nameb('D') // blocks BlockData = nameb('B') // just for testing TestData = nameb('Z') )
Names of the pools
Variables ¶
This section is empty.
Functions ¶
func Initialise ¶
func Initialise(database string)
open up the database connection
this must be called before any pool.New() is created
Types ¶
type Batch ¶ added in v0.1.2
type Batch struct {
// contains filtered or unexported fields
}
type for batch operations
func NewBatch ¶ added in v0.1.2
func NewBatch() *Batch
begin a new batch of Adds and Removes
the adds and removes will be executed only on Commit
type FetchCursor ¶
type FetchCursor struct {
// contains filtered or unexported fields
}
cursor structure
func (*FetchCursor) Fetch ¶
func (cursor *FetchCursor) Fetch(count int) ([]Element, error)
fetch some elements starting from key
func (*FetchCursor) Seek ¶
func (cursor *FetchCursor) Seek(key []byte) *FetchCursor
type IndexedPool ¶
the pool handle
func NewIndexed ¶
func NewIndexed(prefix nameb) *IndexedPool
create a new indexed pool with a specific key prefix
Separate indexes are created to provide a timestamp ordering
func (*IndexedPool) Add ¶
func (p *IndexedPool) Add(key []byte, value []byte) (bool, error)
add a key/value bytes pair to the database
func (*IndexedPool) Get ¶
func (p *IndexedPool) Get(key []byte) ([]byte, error)
read a value for a given key
func (*IndexedPool) Recent ¶
func (p *IndexedPool) Recent(start *gnomon.Cursor, count int, convert func(key []byte, value []byte) interface{}) ([]interface{}, *gnomon.Cursor, error)
fetch the N most recent string key and data pairs
func (*IndexedPool) Remove ¶
func (p *IndexedPool) Remove(key []byte) error
remove a key from the database
type Pool ¶
the pool handle
func (*Pool) Get ¶
read a value for a given key
this returns the actual element - copy the result if it must be preserved
func (*Pool) LastElement ¶
get the last element in a pool
func (*Pool) NewFetchCursor ¶
func (p *Pool) NewFetchCursor() *FetchCursor
initialise a cursor to the start of a key range