Documentation ¶
Index ¶
- Variables
- func TestStorage(t *testing.T, m MockStorage)
- type Factory
- type KV
- type KeyValueStorage
- func (s *KeyValueStorage) Close() error
- func (s *KeyValueStorage) ReadBody(hash types.Hash) (*types.Body, bool)
- func (s *KeyValueStorage) ReadCanonicalHash(n uint64) (types.Hash, bool)
- func (s *KeyValueStorage) ReadDiff(hash types.Hash) (*big.Int, bool)
- func (s *KeyValueStorage) ReadForks() []types.Hash
- func (s *KeyValueStorage) ReadHeadHash() (types.Hash, bool)
- func (s *KeyValueStorage) ReadHeadNumber() (uint64, bool)
- func (s *KeyValueStorage) ReadHeader(hash types.Hash) (*types.Header, bool)
- func (s *KeyValueStorage) ReadReceipts(hash types.Hash) ([]*types.Receipt, bool)
- func (s *KeyValueStorage) ReadSnapshot(hash types.Hash) ([]byte, bool)
- func (s *KeyValueStorage) ReadTxLookup(hash types.Hash) (types.Hash, bool)
- func (s *KeyValueStorage) WriteBody(hash types.Hash, body *types.Body) error
- func (s *KeyValueStorage) WriteCanonicalHash(n uint64, hash types.Hash) error
- func (s *KeyValueStorage) WriteCanonicalHeader(h *types.Header, diff *big.Int) error
- func (s *KeyValueStorage) WriteDiff(hash types.Hash, diff *big.Int) error
- func (s *KeyValueStorage) WriteForks(forks []types.Hash) error
- func (s *KeyValueStorage) WriteHeadHash(h types.Hash) error
- func (s *KeyValueStorage) WriteHeadNumber(n uint64) error
- func (s *KeyValueStorage) WriteHeader(h *types.Header) error
- func (s *KeyValueStorage) WriteReceipts(hash types.Hash, receipts []*types.Receipt) error
- func (s *KeyValueStorage) WriteSnapshot(hash types.Hash, blob []byte) error
- func (s *KeyValueStorage) WriteTxLookup(hash types.Hash, blockHash types.Hash) error
- type MockStorage
- type Storage
Constants ¶
This section is empty.
Variables ¶
var ( // DIFFICULTY is the difficulty prefix DIFFICULTY = []byte("d") // HEADER is the header prefix HEADER = []byte("h") // HEAD is the chain head prefix HEAD = []byte("o") // FORK is the entry to store forks FORK = []byte("f") // CANONICAL is the prefix for the canonical chain numbers CANONICAL = []byte("c") // BODY is the prefix for bodies BODY = []byte("b") // RECEIPTS is the prefix for receipts RECEIPTS = []byte("r") // SNAPSHOTS is the prefix for snapshots SNAPSHOTS = []byte("s") // TRANSACTION is the prefix for transactions TX_LOOKUP_PREFIX = []byte("l") )
var ( HASH = []byte("hash") NUMBER = []byte("number") EMPTY = []byte("empty") )
Functions ¶
func TestStorage ¶
func TestStorage(t *testing.T, m MockStorage)
TestStorage tests a set of tests on a storage
Types ¶
type KV ¶
type KV interface { Close() error Set(p []byte, v []byte) error Get(p []byte) ([]byte, bool, error) }
KV is a key value storage interface
type KeyValueStorage ¶
type KeyValueStorage struct { Db KV // contains filtered or unexported fields }
KeyValueStorage is a generic storage for kv databases
func (*KeyValueStorage) Close ¶
func (s *KeyValueStorage) Close() error
Close closes the connection with the db
func (*KeyValueStorage) ReadCanonicalHash ¶
func (s *KeyValueStorage) ReadCanonicalHash(n uint64) (types.Hash, bool)
ReadCanonicalHash gets the hash from the number of the canonical chain
func (*KeyValueStorage) ReadForks ¶
func (s *KeyValueStorage) ReadForks() []types.Hash
ReadForks read the current forks
func (*KeyValueStorage) ReadHeadHash ¶
func (s *KeyValueStorage) ReadHeadHash() (types.Hash, bool)
ReadHeadHash returns the hash of the head
func (*KeyValueStorage) ReadHeadNumber ¶
func (s *KeyValueStorage) ReadHeadNumber() (uint64, bool)
ReadHeadNumber returns the number of the head
func (*KeyValueStorage) ReadHeader ¶
ReadHeader reads the header
func (*KeyValueStorage) ReadReceipts ¶
ReadReceipts reads the receipts
func (*KeyValueStorage) ReadSnapshot ¶
func (s *KeyValueStorage) ReadSnapshot(hash types.Hash) ([]byte, bool)
ReadBody reads the body
func (*KeyValueStorage) ReadTxLookup ¶
ReadReceipts reads the receipts
func (*KeyValueStorage) WriteCanonicalHash ¶
func (s *KeyValueStorage) WriteCanonicalHash(n uint64, hash types.Hash) error
WriteCanonicalHash writes a hash for a number block in the canonical chain
func (*KeyValueStorage) WriteCanonicalHeader ¶
WriteCanonicalHeader implements the storage interface
func (*KeyValueStorage) WriteForks ¶
func (s *KeyValueStorage) WriteForks(forks []types.Hash) error
WriteForks writes the current forks
func (*KeyValueStorage) WriteHeadHash ¶
func (s *KeyValueStorage) WriteHeadHash(h types.Hash) error
WriteHeadHash writes the hash of the head
func (*KeyValueStorage) WriteHeadNumber ¶
func (s *KeyValueStorage) WriteHeadNumber(n uint64) error
WriteHeadNumber writes the number of the head
func (*KeyValueStorage) WriteHeader ¶
func (s *KeyValueStorage) WriteHeader(h *types.Header) error
WriteHeader writes the header
func (*KeyValueStorage) WriteReceipts ¶
WriteReceipts writes the receipts
func (*KeyValueStorage) WriteSnapshot ¶
func (s *KeyValueStorage) WriteSnapshot(hash types.Hash, blob []byte) error
WriteBody writes the body
func (*KeyValueStorage) WriteTxLookup ¶
WriteReceipts writes the receipts
type MockStorage ¶
type Storage ¶
type Storage interface { ReadCanonicalHash(n uint64) (types.Hash, bool) WriteCanonicalHash(n uint64, hash types.Hash) error ReadHeadHash() (types.Hash, bool) ReadHeadNumber() (uint64, bool) WriteHeadHash(h types.Hash) error WriteHeadNumber(uint64) error WriteForks(forks []types.Hash) error ReadForks() []types.Hash WriteDiff(hash types.Hash, diff *big.Int) error ReadDiff(hash types.Hash) (*big.Int, bool) WriteHeader(h *types.Header) error ReadHeader(hash types.Hash) (*types.Header, bool) WriteCanonicalHeader(h *types.Header, diff *big.Int) error WriteBody(hash types.Hash, body *types.Body) error ReadBody(hash types.Hash) (*types.Body, bool) WriteSnapshot(hash types.Hash, blob []byte) error ReadSnapshot(hash types.Hash) ([]byte, bool) WriteReceipts(hash types.Hash, receipts []*types.Receipt) error ReadReceipts(hash types.Hash) ([]*types.Receipt, bool) WriteTxLookup(hash types.Hash, blockHash types.Hash) error ReadTxLookup(hash types.Hash) (types.Hash, bool) Close() error }
Storage is a generic blockchain storage