Documentation ¶
Index ¶
- Constants
- Variables
- func CleanAddrIdx(db ethdb.Database) error
- func CleanInvalidTxHashs(db ethdb.Database) error
- func CleanInvalidTxs(db ethdb.Database) error
- func CleanSpendJournal(db ethdb.Database) error
- func CleanTokenState(db ethdb.Database) error
- func CleanUtxo(db ethdb.Database) error
- func DeleteBlock(db ethdb.KeyValueWriter, hash *hash.Hash)
- func DeleteBlockID(db ethdb.KeyValueWriter, hash *hash.Hash)
- func DeleteBlockOrderSnapshot(db ethdb.KeyValueWriter, order uint64) error
- func DeleteBody(db ethdb.KeyValueWriter, hash *hash.Hash)
- func DeleteDAGBlock(db ethdb.KeyValueWriter, id uint64)
- func DeleteEstimateFee(db ethdb.KeyValueWriter) error
- func DeleteHeader(db ethdb.KeyValueWriter, hash *hash.Hash)
- func DeleteInvalidTxIdByFullHash(db ethdb.KeyValueWriter, full *hash.Hash) error
- func DeleteInvalidTxLookupEntry(db ethdb.KeyValueWriter, hash *hash.Hash) error
- func DeleteMainChain(db ethdb.KeyValueWriter, id uint64)
- func DeleteSnapshotDisabled(db ethdb.KeyValueWriter)
- func DeleteSnapshotGenerator(db ethdb.KeyValueWriter)
- func DeleteSnapshotJournal(db ethdb.KeyValueWriter)
- func DeleteSnapshotRecoveryNumber(db ethdb.KeyValueWriter)
- func DeleteSnapshotRoot(db ethdb.KeyValueWriter)
- func DeleteSpendJournal(db ethdb.KeyValueWriter, hash *hash.Hash)
- func DeleteTokenState(db ethdb.KeyValueWriter, id uint64)
- func DeleteTxIdByFullHash(db ethdb.KeyValueWriter, full *hash.Hash) error
- func DeleteTxLookupEntry(db ethdb.KeyValueWriter, hash *hash.Hash) error
- func DeleteUtxo(db ethdb.KeyValueWriter, opd []byte)
- func ForeachUtxo(db ethdb.KeyValueStore, fn func(opd []byte, data []byte) error) error
- func HasBody(db ethdb.Reader, hash *hash.Hash) bool
- func HasHeader(db ethdb.Reader, hash *hash.Hash) bool
- func InspectDatabase(db ethdb.Database, keyPrefix, keyStart []byte) error
- func InspectFreezerTable(ancient string, freezerName string, tableName string, start, end int64) error
- func IsInvalidTxEmpty(db ethdb.Iteratee) bool
- func NewDatabase(db ethdb.KeyValueStore) ethdb.Database
- func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace string, readonly bool) (ethdb.Database, error)
- func NewKeyLengthIterator(it ethdb.Iterator, keyLen int) ethdb.Iterator
- func NewLevelDBDatabase(file string, cache int, handles int, namespace string, readonly bool) (ethdb.Database, error)
- func NewMemoryDatabase() ethdb.Database
- func NewMemoryDatabaseWithCap(size int) ethdb.Database
- func NewPebbleDBDatabase(file string, cache int, handles int, namespace string, ...) (ethdb.Database, error)
- func NewTable(db ethdb.Database, prefix string) ethdb.Database
- func Open(o OpenOptions) (ethdb.Database, error)
- func PopUncleanShutdownMarker(db ethdb.KeyValueStore)
- func PreexistingDatabase(path string) string
- func PushUncleanShutdownMarker(db ethdb.KeyValueStore) ([]uint64, uint64, error)
- func ReadAddrIdxTip(db ethdb.Reader) (*hash.Hash, uint, error)
- func ReadBestChainState(db ethdb.Reader) []byte
- func ReadBlockHashByID(db ethdb.Reader, id uint64) (*hash.Hash, error)
- func ReadBlockID(db ethdb.Reader, hash *hash.Hash) *uint64
- func ReadBlockOrderSnapshot(db ethdb.KeyValueReader, order uint64) *uint64
- func ReadBody(db ethdb.Reader, hash *hash.Hash) *types.SerializedBlock
- func ReadBodyByID(db ethdb.Reader, id uint64) *types.SerializedBlock
- func ReadBodyRaw(db ethdb.Reader, hash *hash.Hash) []byte
- func ReadBodyRawByID(db ethdb.Reader, id uint64) []byte
- func ReadChainMetadata(db ethdb.KeyValueStore) [][]string
- func ReadDAGBlock(db ethdb.Reader, id uint64) meerdag.IBlock
- func ReadDAGBlockBaw(db ethdb.Reader, id uint64) []byte
- func ReadDAGInfo(db ethdb.Reader) []byte
- func ReadDAGTips(db ethdb.Reader) []uint64
- func ReadDatabaseBlockIndexVersion(db ethdb.KeyValueReader) *uint32
- func ReadDatabaseCompressionVersion(db ethdb.KeyValueReader) *uint32
- func ReadDatabaseCreate(db ethdb.KeyValueReader) *time.Time
- func ReadDatabaseVersion(db ethdb.KeyValueReader) *uint32
- func ReadDiffAnticone(db ethdb.Reader) []uint64
- func ReadEstimateFee(db ethdb.Reader) []byte
- func ReadHeader(db ethdb.Reader, hash *hash.Hash) *types.BlockHeader
- func ReadHeaderRaw(db ethdb.Reader, hash *hash.Hash) []byte
- func ReadInvalidTransaction(db ethdb.Reader, hash *hash.Hash) (*types.Tx, uint64, *hash.Hash, int)
- func ReadInvalidTxIdByFullHash(db ethdb.Reader, full *hash.Hash) *hash.Hash
- func ReadInvalidTxLookupEntry(db ethdb.Reader, hash *hash.Hash) *uint64
- func ReadMainChain(db ethdb.Reader, id uint64) bool
- func ReadMainChainTip(db ethdb.Reader) *uint64
- func ReadSnapshotDisabled(db ethdb.KeyValueReader) bool
- func ReadSnapshotGenerator(db ethdb.KeyValueReader) []byte
- func ReadSnapshotJournal(db ethdb.KeyValueReader) []byte
- func ReadSnapshotRecoveryNumber(db ethdb.KeyValueReader) *uint64
- func ReadSnapshotRoot(db ethdb.KeyValueReader) *hash.Hash
- func ReadSnapshotSyncStatus(db ethdb.KeyValueReader) []byte
- func ReadSpendJournal(db ethdb.Reader, hash *hash.Hash) []byte
- func ReadTokenState(db ethdb.Reader, id uint64) []byte
- func ReadTransaction(db ethdb.Reader, hash *hash.Hash) (*types.Tx, uint64, *hash.Hash, int)
- func ReadTxIdByFullHash(db ethdb.Reader, full *hash.Hash) *hash.Hash
- func ReadTxLookupEntry(db ethdb.Reader, hash *hash.Hash) *uint64
- func ReadUtxo(db ethdb.Reader, opd []byte) []byte
- func UpdateUncleanShutdownMarker(db ethdb.KeyValueStore)
- func UseLogger(logger l.Logger)
- func WriteAddrIdxTip(db ethdb.KeyValueWriter, bh *hash.Hash, order uint) error
- func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.SerializedBlock, ...) (int64, error)
- func WriteBestChainState(db ethdb.KeyValueWriter, data []byte) error
- func WriteBlock(db ethdb.KeyValueWriter, block *types.SerializedBlock) error
- func WriteBlockID(db ethdb.KeyValueWriter, hash *hash.Hash, id uint64)
- func WriteBlockOrderSnapshot(db ethdb.KeyValueWriter, order uint64, id uint64) error
- func WriteBody(db ethdb.KeyValueWriter, block *types.SerializedBlock) error
- func WriteDAGBlock(db ethdb.KeyValueWriter, block meerdag.IBlock) error
- func WriteDAGBlockRaw(db ethdb.KeyValueWriter, id uint, data []byte) error
- func WriteDAGInfo(db ethdb.KeyValueWriter, data []byte) error
- func WriteDAGTips(db ethdb.KeyValueWriter, tips []uint64) error
- func WriteDatabaseBlockIndexVersion(db ethdb.KeyValueWriter, version uint32) error
- func WriteDatabaseCompressionVersion(db ethdb.KeyValueWriter, version uint32) error
- func WriteDatabaseCreate(db ethdb.KeyValueWriter, create time.Time) error
- func WriteDatabaseVersion(db ethdb.KeyValueWriter, version uint32) error
- func WriteDiffAnticone(db ethdb.KeyValueWriter, da []uint64) error
- func WriteEstimateFee(db ethdb.KeyValueWriter, data []byte) error
- func WriteHeader(db ethdb.KeyValueWriter, header *types.BlockHeader) error
- func WriteInvalidTxIdByFullHash(db ethdb.KeyValueWriter, full *hash.Hash, id *hash.Hash) error
- func WriteInvalidTxLookupEntriesByBlock(db ethdb.KeyValueWriter, block *types.SerializedBlock, id uint64) error
- func WriteMainChain(db ethdb.KeyValueWriter, id uint64) error
- func WriteSnapshotDisabled(db ethdb.KeyValueWriter)
- func WriteSnapshotGenerator(db ethdb.KeyValueWriter, generator []byte)
- func WriteSnapshotJournal(db ethdb.KeyValueWriter, journal []byte)
- func WriteSnapshotRecoveryNumber(db ethdb.KeyValueWriter, number uint64)
- func WriteSnapshotRoot(db ethdb.KeyValueWriter, root *hash.Hash)
- func WriteSnapshotSyncStatus(db ethdb.KeyValueWriter, status []byte)
- func WriteSpendJournal(db ethdb.KeyValueWriter, hash *hash.Hash, data []byte) error
- func WriteTokenState(db ethdb.KeyValueWriter, id uint64, data []byte) error
- func WriteTxIdByFullHash(db ethdb.KeyValueWriter, full *hash.Hash, id *hash.Hash) error
- func WriteTxLookupEntriesByBlock(db ethdb.KeyValueWriter, block *types.SerializedBlock, id uint64) error
- func WriteTxLookupEntry(db ethdb.KeyValueWriter, hash *hash.Hash, id uint64) error
- func WriteUtxo(db ethdb.KeyValueWriter, opd []byte, data []byte) error
- type Freezer
- func (f *Freezer) Ancient(kind string, number uint64) ([]byte, error)
- func (f *Freezer) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error)
- func (f *Freezer) AncientSize(kind string) (uint64, error)
- func (f *Freezer) Ancients() (uint64, error)
- func (f *Freezer) Close() error
- func (f *Freezer) HasAncient(kind string, number uint64) (bool, error)
- func (f *Freezer) MigrateTable(kind string, convert convertLegacyFn) error
- func (f *Freezer) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (writeSize int64, err error)
- func (f *Freezer) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error)
- func (f *Freezer) Sync() error
- func (f *Freezer) Tail() (uint64, error)
- func (f *Freezer) TruncateHead(items uint64) (uint64, error)
- func (f *Freezer) TruncateTail(tail uint64) (uint64, error)
- type KeyLengthIterator
- type OpenOptions
- type ResettableFreezer
- func (f *ResettableFreezer) Ancient(kind string, number uint64) ([]byte, error)
- func (f *ResettableFreezer) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error)
- func (f *ResettableFreezer) AncientSize(kind string) (uint64, error)
- func (f *ResettableFreezer) Ancients() (uint64, error)
- func (f *ResettableFreezer) Close() error
- func (f *ResettableFreezer) HasAncient(kind string, number uint64) (bool, error)
- func (f *ResettableFreezer) MigrateTable(kind string, convert convertLegacyFn) error
- func (f *ResettableFreezer) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (writeSize int64, err error)
- func (f *ResettableFreezer) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error)
- func (f *ResettableFreezer) Reset() error
- func (f *ResettableFreezer) Sync() error
- func (f *ResettableFreezer) Tail() (uint64, error)
- func (f *ResettableFreezer) TruncateHead(items uint64) (uint64, error)
- func (f *ResettableFreezer) TruncateTail(tail uint64) (uint64, error)
Constants ¶
const ( ChainFreezerHeaderTable = "headers" ChainFreezerBlockTable = "blocks" ChainFreezerDAGBlockTable = "dagblocks" )
The list of table names of chain freezer.
const PebbleEnabled = true
Pebble is unsuported on 32bit architecture
Variables ¶
var ( // VersionKeyName is the name of the database key used to house // the database version. It is itself under the BCDBInfoBucketName // bucket. VersionKey = []byte("version") // CompressionVersionKeyName is the name of the database key // used to house the database compression version. It is itself under // the BCDBInfoBucketName bucket. CompressionVersionKey = []byte("compver") // BlockIndexVersionKeyName is the name of the database key // used to house the database block index version. It is itself under // the BCDBInfoBucketName bucket. BlockIndexVersionKey = []byte("bidxver") // CreatedKeyName is the name of the database key used to house // date the database was created. It is itself under the // BCDBInfoBucketName bucket. CreatedKey = []byte("created") // SnapshotRootKey tracks the hash of the last snapshot. SnapshotRootKey = []byte("SnapshotRoot") AddridxPrefix = []byte("A") // snapshot SnapshotBlockOrderPrefix = []byte("o") // SnapshotBlockOrderPrefix + block order -> block id SnapshotBlockStatusPrefix = []byte("s") // SnapshotBlockStatusPrefix + block id -> block status // EstimateFeeDatabaseKey is the key that we use to // store the fee estimator in the database. EstimateFeeDatabaseKey = []byte("estimatefee") )
The fields below define the low level database schema prefixing.
Functions ¶
func CleanAddrIdx ¶
func CleanInvalidTxHashs ¶
func CleanInvalidTxs ¶
func CleanSpendJournal ¶
func CleanTokenState ¶
func DeleteBlock ¶
func DeleteBlock(db ethdb.KeyValueWriter, hash *hash.Hash)
func DeleteBlockID ¶
func DeleteBlockID(db ethdb.KeyValueWriter, hash *hash.Hash)
func DeleteBlockOrderSnapshot ¶
func DeleteBlockOrderSnapshot(db ethdb.KeyValueWriter, order uint64) error
func DeleteBody ¶
func DeleteBody(db ethdb.KeyValueWriter, hash *hash.Hash)
func DeleteDAGBlock ¶
func DeleteDAGBlock(db ethdb.KeyValueWriter, id uint64)
func DeleteEstimateFee ¶
func DeleteEstimateFee(db ethdb.KeyValueWriter) error
func DeleteHeader ¶
func DeleteHeader(db ethdb.KeyValueWriter, hash *hash.Hash)
func DeleteInvalidTxIdByFullHash ¶
func DeleteInvalidTxIdByFullHash(db ethdb.KeyValueWriter, full *hash.Hash) error
func DeleteInvalidTxLookupEntry ¶
func DeleteInvalidTxLookupEntry(db ethdb.KeyValueWriter, hash *hash.Hash) error
func DeleteMainChain ¶
func DeleteMainChain(db ethdb.KeyValueWriter, id uint64)
func DeleteSnapshotDisabled ¶
func DeleteSnapshotDisabled(db ethdb.KeyValueWriter)
DeleteSnapshotDisabled deletes the flag keeping the snapshot maintenance disabled.
func DeleteSnapshotGenerator ¶
func DeleteSnapshotGenerator(db ethdb.KeyValueWriter)
DeleteSnapshotGenerator deletes the serialized snapshot generator saved at the last shutdown
func DeleteSnapshotJournal ¶
func DeleteSnapshotJournal(db ethdb.KeyValueWriter)
DeleteSnapshotJournal deletes the serialized in-memory diff layers saved at the last shutdown
func DeleteSnapshotRecoveryNumber ¶
func DeleteSnapshotRecoveryNumber(db ethdb.KeyValueWriter)
DeleteSnapshotRecoveryNumber deletes the block number of the last persisted snapshot layer.
func DeleteSnapshotRoot ¶
func DeleteSnapshotRoot(db ethdb.KeyValueWriter)
DeleteSnapshotRoot deletes the hash of the block whose state is contained in the persisted snapshot. Since snapshots are not immutable, this method can be used during updates, so a crash or failure will mark the entire snapshot invalid.
func DeleteSpendJournal ¶
func DeleteSpendJournal(db ethdb.KeyValueWriter, hash *hash.Hash)
func DeleteTokenState ¶
func DeleteTokenState(db ethdb.KeyValueWriter, id uint64)
func DeleteTxIdByFullHash ¶
func DeleteTxIdByFullHash(db ethdb.KeyValueWriter, full *hash.Hash) error
func DeleteTxLookupEntry ¶
func DeleteTxLookupEntry(db ethdb.KeyValueWriter, hash *hash.Hash) error
func DeleteUtxo ¶
func DeleteUtxo(db ethdb.KeyValueWriter, opd []byte)
func ForeachUtxo ¶
func InspectDatabase ¶
InspectDatabase traverses the entire database and checks the size of all different categories of data.
func InspectFreezerTable ¶
func InspectFreezerTable(ancient string, freezerName string, tableName string, start, end int64) error
InspectFreezerTable dumps out the index of a specific freezer table. The passed ancient indicates the path of root ancient directory where the chain freezer can be opened. Start and end specify the range for dumping out indexes. Note this function can only be used for debugging purposes.
func IsInvalidTxEmpty ¶
func NewDatabase ¶
func NewDatabase(db ethdb.KeyValueStore) ethdb.Database
NewDatabase creates a high level database on top of a given key-value data store without a freezer moving immutable chain segments into cold storage.
func NewDatabaseWithFreezer ¶
func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace string, readonly bool) (ethdb.Database, error)
NewDatabaseWithFreezer creates a high level database on top of a given key- value data store with a freezer moving immutable chain segments into cold storage. The passed ancient indicates the path of root ancient directory where the chain freezer can be opened.
func NewKeyLengthIterator ¶
NewKeyLengthIterator returns a wrapped version of the iterator that will only return key-value pairs where keys with a specific key length will be returned.
func NewLevelDBDatabase ¶
func NewLevelDBDatabase(file string, cache int, handles int, namespace string, readonly bool) (ethdb.Database, error)
NewLevelDBDatabase creates a persistent key-value database without a freezer moving immutable chain segments into cold storage.
func NewMemoryDatabase ¶
NewMemoryDatabase creates an ephemeral in-memory key-value database without a freezer moving immutable chain segments into cold storage.
func NewMemoryDatabaseWithCap ¶
NewMemoryDatabaseWithCap creates an ephemeral in-memory key-value database with an initial starting capacity, but without a freezer moving immutable chain segments into cold storage.
func NewPebbleDBDatabase ¶
func NewPebbleDBDatabase(file string, cache int, handles int, namespace string, readonly, ephemeral bool) (ethdb.Database, error)
NewPebbleDBDatabase creates a persistent key-value database without a freezer moving immutable chain segments into cold storage.
func Open ¶
func Open(o OpenOptions) (ethdb.Database, error)
Open opens both a disk-based key-value database such as leveldb or pebble, but also integrates it with a freezer database -- if the AncientDir option has been set on the provided OpenOptions. The passed o.AncientDir indicates the path of root ancient directory where the chain freezer can be opened.
func PopUncleanShutdownMarker ¶
func PopUncleanShutdownMarker(db ethdb.KeyValueStore)
PopUncleanShutdownMarker removes the last unclean shutdown marker
func PreexistingDatabase ¶
PreexistingDatabase checks the given data directory whether a database is already instantiated at that location, and if so, returns the type of database (or the empty string).
func PushUncleanShutdownMarker ¶
func PushUncleanShutdownMarker(db ethdb.KeyValueStore) ([]uint64, uint64, error)
PushUncleanShutdownMarker appends a new unclean shutdown marker and returns the previous data - a list of timestamps - a count of how many old unclean-shutdowns have been discarded
func ReadBlockOrderSnapshot ¶
func ReadBlockOrderSnapshot(db ethdb.KeyValueReader, order uint64) *uint64
func ReadBodyByID ¶
func ReadBodyByID(db ethdb.Reader, id uint64) *types.SerializedBlock
func ReadChainMetadata ¶
func ReadChainMetadata(db ethdb.KeyValueStore) [][]string
ReadChainMetadata returns a set of key/value pairs that contains informatin about the database chain status. This can be used for diagnostic purposes when investigating the state of the node.
func ReadDatabaseBlockIndexVersion ¶
func ReadDatabaseBlockIndexVersion(db ethdb.KeyValueReader) *uint32
func ReadDatabaseCompressionVersion ¶
func ReadDatabaseCompressionVersion(db ethdb.KeyValueReader) *uint32
func ReadDatabaseCreate ¶
func ReadDatabaseCreate(db ethdb.KeyValueReader) *time.Time
func ReadDatabaseVersion ¶
func ReadDatabaseVersion(db ethdb.KeyValueReader) *uint32
func ReadHeader ¶
func ReadInvalidTransaction ¶
func ReadInvalidTxIdByFullHash ¶
tx full hash
func ReadInvalidTxLookupEntry ¶
invalid tx index
func ReadMainChainTip ¶
func ReadSnapshotDisabled ¶
func ReadSnapshotDisabled(db ethdb.KeyValueReader) bool
ReadSnapshotDisabled retrieves if the snapshot maintenance is disabled.
func ReadSnapshotGenerator ¶
func ReadSnapshotGenerator(db ethdb.KeyValueReader) []byte
ReadSnapshotGenerator retrieves the serialized snapshot generator saved at the last shutdown.
func ReadSnapshotJournal ¶
func ReadSnapshotJournal(db ethdb.KeyValueReader) []byte
func ReadSnapshotRecoveryNumber ¶
func ReadSnapshotRecoveryNumber(db ethdb.KeyValueReader) *uint64
ReadSnapshotRecoveryNumber retrieves the block number of the last persisted snapshot layer.
func ReadSnapshotRoot ¶
func ReadSnapshotRoot(db ethdb.KeyValueReader) *hash.Hash
ReadSnapshotRoot retrieves the root of the block whose state is contained in the persisted snapshot.
func ReadSnapshotSyncStatus ¶
func ReadSnapshotSyncStatus(db ethdb.KeyValueReader) []byte
ReadSnapshotSyncStatus retrieves the serialized sync status saved at shutdown.
func ReadTransaction ¶
func ReadTxIdByFullHash ¶
tx full hash
func UpdateUncleanShutdownMarker ¶
func UpdateUncleanShutdownMarker(db ethdb.KeyValueStore)
UpdateUncleanShutdownMarker updates the last marker's timestamp to now.
func WriteAddrIdxTip ¶
func WriteAncientBlocks ¶
func WriteAncientBlocks(db ethdb.AncientWriter, blocks []*types.SerializedBlock, dagblocks []meerdag.IBlock) (int64, error)
func WriteBestChainState ¶
func WriteBestChainState(db ethdb.KeyValueWriter, data []byte) error
func WriteBlock ¶
func WriteBlock(db ethdb.KeyValueWriter, block *types.SerializedBlock) error
func WriteBlockID ¶
func WriteBlockID(db ethdb.KeyValueWriter, hash *hash.Hash, id uint64)
func WriteBlockOrderSnapshot ¶
func WriteBlockOrderSnapshot(db ethdb.KeyValueWriter, order uint64, id uint64) error
func WriteBody ¶
func WriteBody(db ethdb.KeyValueWriter, block *types.SerializedBlock) error
func WriteDAGBlock ¶
func WriteDAGBlock(db ethdb.KeyValueWriter, block meerdag.IBlock) error
func WriteDAGBlockRaw ¶
func WriteDAGBlockRaw(db ethdb.KeyValueWriter, id uint, data []byte) error
func WriteDAGInfo ¶
func WriteDAGInfo(db ethdb.KeyValueWriter, data []byte) error
func WriteDAGTips ¶
func WriteDAGTips(db ethdb.KeyValueWriter, tips []uint64) error
func WriteDatabaseBlockIndexVersion ¶
func WriteDatabaseBlockIndexVersion(db ethdb.KeyValueWriter, version uint32) error
func WriteDatabaseCompressionVersion ¶
func WriteDatabaseCompressionVersion(db ethdb.KeyValueWriter, version uint32) error
func WriteDatabaseCreate ¶
func WriteDatabaseCreate(db ethdb.KeyValueWriter, create time.Time) error
func WriteDatabaseVersion ¶
func WriteDatabaseVersion(db ethdb.KeyValueWriter, version uint32) error
func WriteDiffAnticone ¶
func WriteDiffAnticone(db ethdb.KeyValueWriter, da []uint64) error
func WriteEstimateFee ¶
func WriteEstimateFee(db ethdb.KeyValueWriter, data []byte) error
func WriteHeader ¶
func WriteHeader(db ethdb.KeyValueWriter, header *types.BlockHeader) error
func WriteInvalidTxLookupEntriesByBlock ¶
func WriteInvalidTxLookupEntriesByBlock(db ethdb.KeyValueWriter, block *types.SerializedBlock, id uint64) error
func WriteMainChain ¶
func WriteMainChain(db ethdb.KeyValueWriter, id uint64) error
func WriteSnapshotDisabled ¶
func WriteSnapshotDisabled(db ethdb.KeyValueWriter)
WriteSnapshotDisabled stores the snapshot pause flag.
func WriteSnapshotGenerator ¶
func WriteSnapshotGenerator(db ethdb.KeyValueWriter, generator []byte)
WriteSnapshotGenerator stores the serialized snapshot generator to save at shutdown.
func WriteSnapshotJournal ¶
func WriteSnapshotJournal(db ethdb.KeyValueWriter, journal []byte)
func WriteSnapshotRecoveryNumber ¶
func WriteSnapshotRecoveryNumber(db ethdb.KeyValueWriter, number uint64)
WriteSnapshotRecoveryNumber stores the block number of the last persisted snapshot layer.
func WriteSnapshotRoot ¶
func WriteSnapshotRoot(db ethdb.KeyValueWriter, root *hash.Hash)
WriteSnapshotRoot stores the root of the block whose state is contained in the persisted snapshot.
func WriteSnapshotSyncStatus ¶
func WriteSnapshotSyncStatus(db ethdb.KeyValueWriter, status []byte)
WriteSnapshotSyncStatus stores the serialized sync status to save at shutdown.
func WriteSpendJournal ¶
func WriteTokenState ¶
func WriteTokenState(db ethdb.KeyValueWriter, id uint64, data []byte) error
func WriteTxIdByFullHash ¶
func WriteTxLookupEntriesByBlock ¶
func WriteTxLookupEntriesByBlock(db ethdb.KeyValueWriter, block *types.SerializedBlock, id uint64) error
func WriteTxLookupEntry ¶
Types ¶
type Freezer ¶
type Freezer struct {
// contains filtered or unexported fields
}
Freezer is a memory mapped append-only database to store immutable ordered data into flat files:
- The append-only nature ensures that disk writes are minimized.
- The memory mapping ensures we can max out system memory for caching without reserving it for go-ethereum. This would also reduce the memory requirements of Geth, and thus also GC overhead.
func NewChainFreezer ¶
NewChainFreezer is a small utility method around NewFreezer that sets the default parameters for the chain storage.
func NewFreezer ¶
func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize uint32, tables map[string]bool) (*Freezer, error)
NewFreezer creates a freezer instance for maintaining immutable ordered data according to the given parameters.
The 'tables' argument defines the data tables. If the value of a map entry is true, snappy compression is disabled for the table.
func (*Freezer) Ancient ¶
Ancient retrieves an ancient binary blob from the append-only immutable files.
func (*Freezer) AncientRange ¶
AncientRange retrieves multiple items in sequence, starting from the index 'start'. It will return
- at most 'count' items,
- if maxBytes is specified: at least 1 item (even if exceeding the maxByteSize), but will otherwise return as many items as fit into maxByteSize.
- if maxBytes is not specified, 'count' items will be returned if they are present.
func (*Freezer) AncientSize ¶
AncientSize returns the ancient size of the specified category.
func (*Freezer) HasAncient ¶
HasAncient returns an indicator whether the specified ancient data exists in the freezer.
func (*Freezer) MigrateTable ¶
MigrateTable processes the entries in a given table in sequence converting them to a new format if they're of an old format.
func (*Freezer) ModifyAncients ¶
ModifyAncients runs the given write operation.
func (*Freezer) ReadAncients ¶
func (f *Freezer) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error)
ReadAncients runs the given read operation while ensuring that no writes take place on the underlying freezer.
func (*Freezer) TruncateHead ¶
TruncateHead discards any recent data above the provided threshold number. It returns the previous head number.
type KeyLengthIterator ¶
KeyLengthIterator is a wrapper for a database iterator that ensures only key-value pairs with a specific key length will be returned.
func (*KeyLengthIterator) Next ¶
func (it *KeyLengthIterator) Next() bool
type OpenOptions ¶
type OpenOptions struct { Type string // "leveldb" | "pebble" Directory string // the datadir AncientsDirectory string // the ancients-dir Namespace string // the namespace for database relevant metrics Cache int // the capacity(in megabytes) of the data caching Handles int // number of files to be open simultaneously ReadOnly bool // Ephemeral means that filesystem sync operations should be avoided: data integrity in the face of // a crash is not important. This option should typically be used in tests. Ephemeral bool }
OpenOptions contains the options to apply when opening a database. OBS: If AncientsDirectory is empty, it indicates that no freezer is to be used.
type ResettableFreezer ¶
type ResettableFreezer struct {
// contains filtered or unexported fields
}
ResettableFreezer is a wrapper of the freezer which makes the freezer resettable.
func NewResettableFreezer ¶
func NewResettableFreezer(datadir string, namespace string, readonly bool, maxTableSize uint32, tables map[string]bool) (*ResettableFreezer, error)
NewResettableFreezer creates a resettable freezer, note freezer is only resettable if the passed file directory is exclusively occupied by the freezer. And also the user-configurable ancient root directory is **not** supported for reset since it might be a mount and rename will cause a copy of hundreds of gigabyte into local directory. It needs some other file based solutions.
The reset function will delete directory atomically and re-create the freezer from scratch.
func NewStateFreezer ¶
func NewStateFreezer(ancientDir string, readOnly bool) (*ResettableFreezer, error)
NewStateFreezer initializes the freezer for state history.
func (*ResettableFreezer) Ancient ¶
func (f *ResettableFreezer) Ancient(kind string, number uint64) ([]byte, error)
Ancient retrieves an ancient binary blob from the append-only immutable files.
func (*ResettableFreezer) AncientRange ¶
func (f *ResettableFreezer) AncientRange(kind string, start, count, maxBytes uint64) ([][]byte, error)
AncientRange retrieves multiple items in sequence, starting from the index 'start'. It will return
- at most 'max' items,
- at least 1 item (even if exceeding the maxByteSize), but will otherwise return as many items as fit into maxByteSize
func (*ResettableFreezer) AncientSize ¶
func (f *ResettableFreezer) AncientSize(kind string) (uint64, error)
AncientSize returns the ancient size of the specified category.
func (*ResettableFreezer) Ancients ¶
func (f *ResettableFreezer) Ancients() (uint64, error)
Ancients returns the length of the frozen items.
func (*ResettableFreezer) Close ¶
func (f *ResettableFreezer) Close() error
Close terminates the chain freezer, unmapping all the data files.
func (*ResettableFreezer) HasAncient ¶
func (f *ResettableFreezer) HasAncient(kind string, number uint64) (bool, error)
HasAncient returns an indicator whether the specified ancient data exists in the freezer
func (*ResettableFreezer) MigrateTable ¶
func (f *ResettableFreezer) MigrateTable(kind string, convert convertLegacyFn) error
MigrateTable processes the entries in a given table in sequence converting them to a new format if they're of an old format.
func (*ResettableFreezer) ModifyAncients ¶
func (f *ResettableFreezer) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (writeSize int64, err error)
ModifyAncients runs the given write operation.
func (*ResettableFreezer) ReadAncients ¶
func (f *ResettableFreezer) ReadAncients(fn func(ethdb.AncientReaderOp) error) (err error)
ReadAncients runs the given read operation while ensuring that no writes take place on the underlying freezer.
func (*ResettableFreezer) Reset ¶
func (f *ResettableFreezer) Reset() error
Reset deletes the file directory exclusively occupied by the freezer and recreate the freezer from scratch. The atomicity of directory deletion is guaranteed by the rename operation, the leftover directory will be cleaned up in next startup in case crash happens after rename.
func (*ResettableFreezer) Sync ¶
func (f *ResettableFreezer) Sync() error
Sync flushes all data tables to disk.
func (*ResettableFreezer) Tail ¶
func (f *ResettableFreezer) Tail() (uint64, error)
Tail returns the number of first stored item in the freezer.
func (*ResettableFreezer) TruncateHead ¶
func (f *ResettableFreezer) TruncateHead(items uint64) (uint64, error)
TruncateHead discards any recent data above the provided threshold number. It returns the previous head number.
func (*ResettableFreezer) TruncateTail ¶
func (f *ResettableFreezer) TruncateTail(tail uint64) (uint64, error)
TruncateTail discards any recent data below the provided threshold number. It returns the previous value
Source Files ¶
- accessors_chain.go
- accessors_dag.go
- accessors_indexes.go
- accessors_metadata.go
- accessors_snapshot.go
- ancient_scheme.go
- ancient_utils.go
- chain_freezer.go
- database.go
- databases_64bit.go
- freezer.go
- freezer_batch.go
- freezer_meta.go
- freezer_resettable.go
- freezer_table.go
- freezer_utils.go
- key_length_iterator.go
- log.go
- schema.go
- table.go