Documentation ¶
Index ¶
- Constants
- Variables
- func NewHeightLimitedIterator(atHeight int64, oit tmdb.Iterator) tmdb.Iterator
- type HLD
- type Height
- type HeightLimitEnabledBatch
- type HeightLimitEnabledDB
- type HeightLimitEnabledIterator
- type HeightLimitedDB
- func (hld *HeightLimitedDB) BranchHeightLimitedDB(height int64) *HeightLimitedDB
- func (hld *HeightLimitedDB) ClearReadHeight() int64
- func (hld *HeightLimitedDB) ClearWriteHeight() int64
- func (hld *HeightLimitedDB) Close() error
- func (hld *HeightLimitedDB) Debug(debugType int, key []byte, value []byte)
- func (hld *HeightLimitedDB) Delete(key []byte) error
- func (hld *HeightLimitedDB) DeleteSync(key []byte) error
- func (hld *HeightLimitedDB) Get(key []byte) ([]byte, error)
- func (hld *HeightLimitedDB) GetCurrentReadHeight() int64
- func (hld *HeightLimitedDB) GetCurrentWriteHeight() int64
- func (hld *HeightLimitedDB) Has(key []byte) (bool, error)
- func (hld *HeightLimitedDB) Iterator(start, end []byte) (tmdb.Iterator, error)
- func (hld *HeightLimitedDB) NewBatch() tmdb.Batch
- func (hld *HeightLimitedDB) Print() error
- func (hld *HeightLimitedDB) ReverseIterator(start, end []byte) (tmdb.Iterator, error)
- func (hld *HeightLimitedDB) Set(key []byte, value []byte) error
- func (hld *HeightLimitedDB) SetReadHeight(height int64)
- func (hld *HeightLimitedDB) SetSync(key []byte, value []byte) error
- func (hld *HeightLimitedDB) SetWriteHeight(height int64)
- func (hld *HeightLimitedDB) Stats() map[string]string
- type HeightLimitedDBConfig
- type HeightLimitedDBIterator
- func (h *HeightLimitedDBIterator) Close() error
- func (h *HeightLimitedDBIterator) Domain() (start []byte, end []byte)
- func (h *HeightLimitedDBIterator) Error() error
- func (h *HeightLimitedDBIterator) Key() (key []byte)
- func (h *HeightLimitedDBIterator) Next()
- func (h *HeightLimitedDBIterator) Valid() bool
- func (h *HeightLimitedDBIterator) Value() (value []byte)
- type Key
Constants ¶
const ( LatestHeight = 0 InvalidHeight = 0 )
Variables ¶
var HeightLimitedDelimiter = []byte{'@'}
var LatestHeightBuf = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
Functions ¶
Types ¶
type Height ¶
type Height int64
func (Height) Cluster ¶
Cluster returns /1000 of the height; useful for clustering records in different partitions
func (Height) CurrentOrLatest ¶
func (Height) CurrentOrNever ¶
func (Height) IsLatestHeight ¶
type HeightLimitEnabledBatch ¶
type HeightLimitEnabledDB ¶
type HeightLimitEnabledDB interface { // Get fetches the value of the given key, or nil if it does not exist. // CONTRACT: key, value readonly []byte Get(maxHeight int64, key []byte) ([]byte, error) // Has checks if a key exists. // CONTRACT: key, value readonly []byte Has(maxHeight int64, key []byte) (bool, error) // Set sets the value for the given key, replacing it if it already exists. // CONTRACT: key, value readonly []byte Set(atHeight int64, key, value []byte) error // SetSync sets the value for the given key, and flushes it to storage before returning. SetSync(atHeight int64, key, value []byte) error // Delete deletes the key, or does nothing if the key does not exist. // CONTRACT: key readonly []byte Delete(atHeight int64, key []byte) error // DeleteSync deletes the key, and flushes the delete to storage before returning. DeleteSync(atHeight int64, key []byte) error // Iterator returns an iterator over a domain of keys, in ascending order. The caller must call // Close when done. End is exclusive, and start must be less than end. A nil start iterates // from the first key, and a nil end iterates to the last key (inclusive). // CONTRACT: No writes may happen within a domain while an iterator exists over it. // CONTRACT: start, end readonly []byte Iterator(maxHeight int64, start, end []byte) (HeightLimitEnabledIterator, error) // ReverseIterator returns an iterator over a domain of keys, in descending order. The caller // must call Close when done. End is exclusive, and start must be less than end. A nil end // iterates from the last key (inclusive), and a nil start iterates to the first key (inclusive). // CONTRACT: No writes may happen within a domain while an iterator exists over it. // CONTRACT: start, end readonly []byte ReverseIterator(maxHeight int64, start, end []byte) (HeightLimitEnabledIterator, error) // Close closes the database connection. Close() error // NewBatch creates a batch for atomic updates. The caller must call Batch.Close. NewBatch(atHeight int64) HeightLimitEnabledBatch // Print is used for debugging. Print() error // Stats returns a map of property values for all keys and the size of the cache. Stats() map[string]string }
type HeightLimitedDB ¶
type HeightLimitedDB struct {
// contains filtered or unexported fields
}
func ApplyHeightLimitedDB ¶
func ApplyHeightLimitedDB(db HeightLimitEnabledDB, config *HeightLimitedDBConfig) *HeightLimitedDB
func (*HeightLimitedDB) BranchHeightLimitedDB ¶
func (hld *HeightLimitedDB) BranchHeightLimitedDB(height int64) *HeightLimitedDB
func (*HeightLimitedDB) ClearReadHeight ¶
func (hld *HeightLimitedDB) ClearReadHeight() int64
ClearReadHeight sets internal readHeight to LatestHeight
func (*HeightLimitedDB) ClearWriteHeight ¶
func (hld *HeightLimitedDB) ClearWriteHeight() int64
ClearWriteHeight sets the next target write Height NOTE: evaluate the actual usage of it
func (*HeightLimitedDB) Close ¶
func (hld *HeightLimitedDB) Close() error
Close closes the database connection.
func (*HeightLimitedDB) Debug ¶
func (hld *HeightLimitedDB) Debug(debugType int, key []byte, value []byte)
func (*HeightLimitedDB) Delete ¶
func (hld *HeightLimitedDB) Delete(key []byte) error
Delete deletes the key, or does nothing if the key does not exist. CONTRACT: key readonly []byte NOTE(mantlemint): delete should be marked?
func (*HeightLimitedDB) DeleteSync ¶
func (hld *HeightLimitedDB) DeleteSync(key []byte) error
DeleteSync deletes the key, and flushes the delete to storage before returning.
func (*HeightLimitedDB) Get ¶
func (hld *HeightLimitedDB) Get(key []byte) ([]byte, error)
Get fetches the value of the given key, or nil if it does not exist. CONTRACT: key, value readonly []byte
func (*HeightLimitedDB) GetCurrentReadHeight ¶
func (hld *HeightLimitedDB) GetCurrentReadHeight() int64
GetCurrentReadHeight gets the current readHeight
func (*HeightLimitedDB) GetCurrentWriteHeight ¶
func (hld *HeightLimitedDB) GetCurrentWriteHeight() int64
GetCurrentWriteHeight gets the current write height
func (*HeightLimitedDB) Has ¶
func (hld *HeightLimitedDB) Has(key []byte) (bool, error)
Has checks if a key exists. CONTRACT: key, value readonly []byte
func (*HeightLimitedDB) Iterator ¶
func (hld *HeightLimitedDB) Iterator(start, end []byte) (tmdb.Iterator, error)
Iterator returns an iterator over a domain of keys, in ascending order. The caller must call Close when done. End is exclusive, and start must be less than end. A nil start iterates from the first key, and a nil end iterates to the last key (inclusive). CONTRACT: No writes may happen within a domain while an iterator exists over it. CONTRACT: start, end readonly []byte
func (*HeightLimitedDB) NewBatch ¶
func (hld *HeightLimitedDB) NewBatch() tmdb.Batch
NewBatch creates a batch for atomic updates. The caller must call Batch.Close.
func (*HeightLimitedDB) Print ¶
func (hld *HeightLimitedDB) Print() error
Print is used for debugging.
func (*HeightLimitedDB) ReverseIterator ¶
func (hld *HeightLimitedDB) ReverseIterator(start, end []byte) (tmdb.Iterator, error)
ReverseIterator returns an iterator over a domain of keys, in descending order. The caller must call Close when done. End is exclusive, and start must be less than end. A nil end iterates from the last key (inclusive), and a nil start iterates to the first key (inclusive). CONTRACT: No writes may happen within a domain while an iterator exists over it. CONTRACT: start, end readonly []byte
func (*HeightLimitedDB) Set ¶
func (hld *HeightLimitedDB) Set(key []byte, value []byte) error
Set sets the value for the given key, replacing it if it already exists. CONTRACT: key, value readonly []byte
func (*HeightLimitedDB) SetReadHeight ¶
func (hld *HeightLimitedDB) SetReadHeight(height int64)
SetReadHeight sets a target read height in the db driver. It acts differently if the db mode is writer or reader:
- Reader uses readHeight as the max height at which the retrieved key/value pair is limited to, allowing full block snapshot history
func (*HeightLimitedDB) SetSync ¶
func (hld *HeightLimitedDB) SetSync(key []byte, value []byte) error
SetSync sets the value for the given key, and flushes it to storage before returning.
func (*HeightLimitedDB) SetWriteHeight ¶
func (hld *HeightLimitedDB) SetWriteHeight(height int64)
SetWriteHeight sets a target write height in the db driver. - Writer uses writeHeight to append along with the key, so later when fetching with the driver you can find the latest known key/value pair before the writeHeight
func (*HeightLimitedDB) Stats ¶
func (hld *HeightLimitedDB) Stats() map[string]string
Stats returns a map of property values for all keys and the size of the cache.
type HeightLimitedDBConfig ¶
type HeightLimitedDBConfig struct {
Debug bool
}
type HeightLimitedDBIterator ¶
type HeightLimitedDBIterator struct {
// contains filtered or unexported fields
}
func (*HeightLimitedDBIterator) Close ¶
func (h *HeightLimitedDBIterator) Close() error
func (*HeightLimitedDBIterator) Domain ¶
func (h *HeightLimitedDBIterator) Domain() (start []byte, end []byte)
func (*HeightLimitedDBIterator) Error ¶
func (h *HeightLimitedDBIterator) Error() error
func (*HeightLimitedDBIterator) Key ¶
func (h *HeightLimitedDBIterator) Key() (key []byte)
func (*HeightLimitedDBIterator) Next ¶
func (h *HeightLimitedDBIterator) Next()
func (*HeightLimitedDBIterator) Valid ¶
func (h *HeightLimitedDBIterator) Valid() bool
func (*HeightLimitedDBIterator) Value ¶
func (h *HeightLimitedDBIterator) Value() (value []byte)