hld

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LatestHeight  = 0
	InvalidHeight = 0
)

Variables

View Source
var HeightLimitedDelimiter = []byte{'@'}
View Source
var LatestHeightBuf = []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}

Functions

func NewHeightLimitedIterator

func NewHeightLimitedIterator(atHeight int64, oit tmdb.Iterator) tmdb.Iterator

Types

type HLD

type HLD interface {
	tmdb.DB
	SetReadHeight(int64)
	ClearReadHeight() int64
	SetWriteHeight(int64)
	ClearWriteHeight() int64
}

type Height

type Height int64

func (Height) Cluster

func (h Height) Cluster() Height

Cluster returns /1000 of the height; useful for clustering records in different partitions

func (Height) CurrentOrLatest

func (h Height) CurrentOrLatest() Height

func (Height) CurrentOrNever

func (h Height) CurrentOrNever() Height

func (Height) IsLatestHeight

func (h Height) IsLatestHeight() bool

func (Height) ToInt64

func (h Height) ToInt64() int64

type HeightLimitEnabledBatch

type HeightLimitEnabledBatch interface {
	tmdb.Batch
}

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 HeightLimitEnabledIterator

type HeightLimitEnabledIterator interface {
	tmdb.Iterator
}

type HeightLimitedDB

type HeightLimitedDB struct {
	// contains filtered or unexported fields
}

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)

type Key

type Key []byte

func (Key) CurrentOrDefault

func (k Key) CurrentOrDefault() []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL