Documentation ¶
Index ¶
- func BuildKey(bucket Bucket, key []byte) (bkey []byte)
- func Decode(o interface{}, data []byte) error
- func Encode(o interface{}) ([]byte, error)
- func HeightToBytes(v int64) []byte
- type Bucket
- type IDatabase
- type Iterator
- type Ldb
- func (db *Ldb) Close() (err error)
- func (db *Ldb) Delete(bucket Bucket, key []byte) error
- func (db *Ldb) Get(bucket Bucket, key []byte) ([]byte, error)
- func (db *Ldb) Iterate(bucket Bucket) (iter Iterator)
- func (db *Ldb) Open(pathname string) (err error)
- func (db *Ldb) Put(bucket Bucket, key []byte, Value []byte) error
- type MapDb
- func (db *MapDb) Close() (err error)
- func (db *MapDb) Delete(bucket Bucket, key []byte) error
- func (db *MapDb) Get(bucket Bucket, key []byte) ([]byte, error)
- func (db *MapDb) Iterate(bucket Bucket) (iter Iterator)
- func (db *MapDb) Open(pathname string) (err error)
- func (db *MapDb) Put(bucket Bucket, key []byte, Value []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildKey ¶
BuildKey() appends the bucket as a number to the front of the key, only using 7 bits and keeping the high bit set. Much like a varint. This does not work well for negative numbers or really big numbers.
This usually this adds two bytes, the value and a zero. The bucket is always separated from the key by one zero. We set the high order bit
func HeightToBytes ¶ added in v0.2.0
Types ¶
type Bucket ¶
type Bucket int
const ( INVALID Bucket = iota // Don't use zero, that's a good invalid value // The bucket indexed by height that has the raw oprblock data // Key -> Height // Value -> Graded opr list BUCKET_OPR_HEIGHT // These are unused BUCKET_OPR // Mostly Valid (has the prior winners, has proper structure BUCKET_ALL_EB // OPR chain Entry Blocks indexed by Directory Block Height BUCKET_VALID_EB // OPR chain Entry Blocks that actually qualify to pay out mining fees and set asset prices BUCKET_VALID_OPRS // OPR Lists of valid OPRS, indexed by Directory Block Height, ordered as graded BUCKET_BALANCES // PEG payout balances )
type Ldb ¶
func (*Ldb) Close ¶
Close() Close the database if it has not yet been closed. We know this by checking that the DB field isn't nil.
func (*Ldb) Iterate ¶
Iterate() Creates an iterator to iterate over the elements in a bucket. A particular iterator cannot be used in multiple processes, but multiple processes can have their own iterators without issue.
Iterators must be released.