current

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 12 Imported by: 1

README

Current Storage

The current storage element of cardinal-storage tracks the current state data of a blockchain. It tracks a number of layers (128 by default) in-memory to be able to handle small reorgs quickly and efficiently (as well as serving requests about recent but not current blocks). As data is consolidated down onto the disk, it also tracks deltas to allow reorgs beyond 128 blocks.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	HashToNumPrefix      = []byte("h")
	NumToHashPrefix      = []byte("n")
	DataPrefix           = []byte("d")
	RollbackPrefix       = []byte("r")
	ResumptionDataKey    = []byte("Resumption")
	LatestBlockHashKey   = []byte("LatestBlockHash")
	LatestBlockWeightKey = []byte("LatestBlockWeight")
	MemoryPersistenceKey = []byte("MemoryPersistence")
)

Functions

func DataKey

func DataKey(key []byte) []byte

func HashToNumKey

func HashToNumKey(h types.Hash) []byte

func New

func New(sdb db.Database, maxDepth int64, whitelist map[uint64]types.Hash) storage.Storage

New starts a currentStorage instance from an empty database.

func NumToHashKey

func NumToHashKey(n uint64) []byte

func Open

func Open(sdb db.Database, maxDepth int64, whitelist map[uint64]types.Hash) (storage.Storage, error)

Open loads a currentStorage instance from a loaded database

func RollbackDelta

func RollbackDelta(n uint64) []byte

Types

type Initializer

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

func NewInitializer

func NewInitializer(db dbpkg.Database) *Initializer

func (*Initializer) AddData

func (init *Initializer) AddData(key, value []byte)

func (*Initializer) Close

func (init *Initializer) Close()

func (*Initializer) SetBlockData

func (init *Initializer) SetBlockData(hash, parentHash types.Hash, number uint64, weight *big.Int)

Jump to

Keyboard shortcuts

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