Documentation ¶
Index ¶
- Variables
- func TestStorage(t *testing.T, m PlaceholderStorage)
- type Factory
- type Forks
- type KV
- type KeyValueStorage
- func (s *KeyValueStorage) Close() error
- func (s *KeyValueStorage) ReadBody(hash types.Hash) (*types.Body, error)
- func (s *KeyValueStorage) ReadCanonicalHash(n uint64) (types.Hash, bool)
- func (s *KeyValueStorage) ReadForks() ([]types.Hash, error)
- func (s *KeyValueStorage) ReadHeadHash() (types.Hash, bool)
- func (s *KeyValueStorage) ReadHeadNumber() (uint64, bool)
- func (s *KeyValueStorage) ReadHeader(hash types.Hash) (*types.Header, error)
- func (s *KeyValueStorage) ReadReceipts(hash types.Hash) ([]*types.Receipt, error)
- func (s *KeyValueStorage) ReadSnapshot(hash types.Hash) ([]byte, bool)
- func (s *KeyValueStorage) ReadTotalDifficulty(hash types.Hash) (*big.Int, 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) 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) WriteTotalDifficulty(hash types.Hash, diff *big.Int) error
- func (s *KeyValueStorage) WriteTxLookup(hash types.Hash, blockHash types.Hash) error
- type MockStorage
- func (m *MockStorage) Close() error
- func (m *MockStorage) HookClose(fn closeDelegate)
- func (m *MockStorage) HookReadBody(fn readBodyDelegate)
- func (m *MockStorage) HookReadCanonicalHash(fn readCanonicalHashDelegate)
- func (m *MockStorage) HookReadForks(fn readForksDelegate)
- func (m *MockStorage) HookReadHeadHash(fn readHeadHashDelegate)
- func (m *MockStorage) HookReadHeadNumber(fn readHeadNumberDelegate)
- func (m *MockStorage) HookReadHeader(fn readHeaderDelegate)
- func (m *MockStorage) HookReadReceipts(fn readReceiptsDelegate)
- func (m *MockStorage) HookReadSnapshot(fn readSnapshotDelegate)
- func (m *MockStorage) HookReadTotalDifficulty(fn readTotalDifficultyDelegate)
- func (m *MockStorage) HookReadTxLookup(fn readTxLookupDelegate)
- func (m *MockStorage) HookWriteBody(fn writeBodyDelegate)
- func (m *MockStorage) HookWriteCanonicalHash(fn writeCanonicalHashDelegate)
- func (m *MockStorage) HookWriteCanonicalHeader(fn writeCanonicalHeaderDelegate)
- func (m *MockStorage) HookWriteForks(fn writeForksDelegate)
- func (m *MockStorage) HookWriteHeadHash(fn writeHeadHashDelegate)
- func (m *MockStorage) HookWriteHeadNumber(fn writeHeadNumberDelegate)
- func (m *MockStorage) HookWriteHeader(fn writeHeaderDelegate)
- func (m *MockStorage) HookWriteReceipts(fn writeReceiptsDelegate)
- func (m *MockStorage) HookWriteSnapshot(fn writeSnapshotDelegate)
- func (m *MockStorage) HookWriteTotalDifficulty(fn writeTotalDifficultyDelegate)
- func (m *MockStorage) HookWriteTxLookup(fn writeTxLookupDelegate)
- func (m *MockStorage) ReadBody(hash types.Hash) (*types.Body, error)
- func (m *MockStorage) ReadCanonicalHash(n uint64) (types.Hash, bool)
- func (m *MockStorage) ReadForks() ([]types.Hash, error)
- func (m *MockStorage) ReadHeadHash() (types.Hash, bool)
- func (m *MockStorage) ReadHeadNumber() (uint64, bool)
- func (m *MockStorage) ReadHeader(hash types.Hash) (*types.Header, error)
- func (m *MockStorage) ReadReceipts(hash types.Hash) ([]*types.Receipt, error)
- func (m *MockStorage) ReadSnapshot(hash types.Hash) ([]byte, bool)
- func (m *MockStorage) ReadTotalDifficulty(hash types.Hash) (*big.Int, bool)
- func (m *MockStorage) ReadTxLookup(hash types.Hash) (types.Hash, bool)
- func (m *MockStorage) WriteBody(hash types.Hash, body *types.Body) error
- func (m *MockStorage) WriteCanonicalHash(n uint64, hash types.Hash) error
- func (m *MockStorage) WriteCanonicalHeader(h *types.Header, diff *big.Int) error
- func (m *MockStorage) WriteForks(forks []types.Hash) error
- func (m *MockStorage) WriteHeadHash(h types.Hash) error
- func (m *MockStorage) WriteHeadNumber(n uint64) error
- func (m *MockStorage) WriteHeader(h *types.Header) error
- func (m *MockStorage) WriteReceipts(hash types.Hash, receipts []*types.Receipt) error
- func (m *MockStorage) WriteSnapshot(hash types.Hash, blob []byte) error
- func (m *MockStorage) WriteTotalDifficulty(hash types.Hash, diff *big.Int) error
- func (m *MockStorage) WriteTxLookup(hash types.Hash, blockHash types.Hash) error
- type PlaceholderStorage
- 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") // TX_LOOKUP_PREFIX is the prefix for transaction lookups TX_LOOKUP_PREFIX = []byte("l") )
Prefixes for the key-value store
var ( HASH = []byte("hash") NUMBER = []byte("number") EMPTY = []byte("empty") )
Sub-prefixes
var ErrNotFound = fmt.Errorf("not found")
Functions ¶
func TestStorage ¶
func TestStorage(t *testing.T, m PlaceholderStorage)
TestStorage tests a set of tests on a storage
Types ¶
type Forks ¶
func (*Forks) MarshalRLPTo ¶
MarshalRLPTo is a wrapper function for calling the type marshal implementation
func (*Forks) MarshalRLPWith ¶
MarshalRLPWith is the actual RLP marshal implementation for the type
func (*Forks) UnmarshalRLP ¶
UnmarshalRLP is a wrapper function for calling the type unmarshal implementation
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.
KV = Key-Value
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, error)
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)
ReadSnapshot reads the snapshot from the DB
func (*KeyValueStorage) ReadTotalDifficulty ¶
ReadTotalDifficulty reads the difficulty
func (*KeyValueStorage) ReadTxLookup ¶
ReadTxLookup reads the block hash using the transaction hash
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
WriteSnapshot writes the snapshot to the DB
func (*KeyValueStorage) WriteTotalDifficulty ¶
WriteTotalDifficulty writes the difficulty
func (*KeyValueStorage) WriteTxLookup ¶
WriteTxLookup maps the transaction hash to the block hash
type MockStorage ¶
type MockStorage struct {
// contains filtered or unexported fields
}
func NewMockStorage ¶ added in v0.5.3
func NewMockStorage() *MockStorage
func (*MockStorage) Close ¶ added in v0.5.3
func (m *MockStorage) Close() error
func (*MockStorage) HookClose ¶ added in v0.5.3
func (m *MockStorage) HookClose(fn closeDelegate)
func (*MockStorage) HookReadBody ¶ added in v0.5.3
func (m *MockStorage) HookReadBody(fn readBodyDelegate)
func (*MockStorage) HookReadCanonicalHash ¶ added in v0.5.3
func (m *MockStorage) HookReadCanonicalHash(fn readCanonicalHashDelegate)
func (*MockStorage) HookReadForks ¶ added in v0.5.3
func (m *MockStorage) HookReadForks(fn readForksDelegate)
func (*MockStorage) HookReadHeadHash ¶ added in v0.5.3
func (m *MockStorage) HookReadHeadHash(fn readHeadHashDelegate)
func (*MockStorage) HookReadHeadNumber ¶ added in v0.5.3
func (m *MockStorage) HookReadHeadNumber(fn readHeadNumberDelegate)
func (*MockStorage) HookReadHeader ¶ added in v0.5.3
func (m *MockStorage) HookReadHeader(fn readHeaderDelegate)
func (*MockStorage) HookReadReceipts ¶ added in v0.5.3
func (m *MockStorage) HookReadReceipts(fn readReceiptsDelegate)
func (*MockStorage) HookReadSnapshot ¶ added in v0.5.3
func (m *MockStorage) HookReadSnapshot(fn readSnapshotDelegate)
func (*MockStorage) HookReadTotalDifficulty ¶ added in v0.5.3
func (m *MockStorage) HookReadTotalDifficulty(fn readTotalDifficultyDelegate)
func (*MockStorage) HookReadTxLookup ¶ added in v0.5.3
func (m *MockStorage) HookReadTxLookup(fn readTxLookupDelegate)
func (*MockStorage) HookWriteBody ¶ added in v0.5.3
func (m *MockStorage) HookWriteBody(fn writeBodyDelegate)
func (*MockStorage) HookWriteCanonicalHash ¶ added in v0.5.3
func (m *MockStorage) HookWriteCanonicalHash(fn writeCanonicalHashDelegate)
func (*MockStorage) HookWriteCanonicalHeader ¶ added in v0.5.3
func (m *MockStorage) HookWriteCanonicalHeader(fn writeCanonicalHeaderDelegate)
func (*MockStorage) HookWriteForks ¶ added in v0.5.3
func (m *MockStorage) HookWriteForks(fn writeForksDelegate)
func (*MockStorage) HookWriteHeadHash ¶ added in v0.5.3
func (m *MockStorage) HookWriteHeadHash(fn writeHeadHashDelegate)
func (*MockStorage) HookWriteHeadNumber ¶ added in v0.5.3
func (m *MockStorage) HookWriteHeadNumber(fn writeHeadNumberDelegate)
func (*MockStorage) HookWriteHeader ¶ added in v0.5.3
func (m *MockStorage) HookWriteHeader(fn writeHeaderDelegate)
func (*MockStorage) HookWriteReceipts ¶ added in v0.5.3
func (m *MockStorage) HookWriteReceipts(fn writeReceiptsDelegate)
func (*MockStorage) HookWriteSnapshot ¶ added in v0.5.3
func (m *MockStorage) HookWriteSnapshot(fn writeSnapshotDelegate)
func (*MockStorage) HookWriteTotalDifficulty ¶ added in v0.5.3
func (m *MockStorage) HookWriteTotalDifficulty(fn writeTotalDifficultyDelegate)
func (*MockStorage) HookWriteTxLookup ¶ added in v0.5.3
func (m *MockStorage) HookWriteTxLookup(fn writeTxLookupDelegate)
func (*MockStorage) ReadCanonicalHash ¶ added in v0.5.3
func (m *MockStorage) ReadCanonicalHash(n uint64) (types.Hash, bool)
func (*MockStorage) ReadForks ¶ added in v0.5.3
func (m *MockStorage) ReadForks() ([]types.Hash, error)
func (*MockStorage) ReadHeadHash ¶ added in v0.5.3
func (m *MockStorage) ReadHeadHash() (types.Hash, bool)
func (*MockStorage) ReadHeadNumber ¶ added in v0.5.3
func (m *MockStorage) ReadHeadNumber() (uint64, bool)
func (*MockStorage) ReadHeader ¶ added in v0.5.3
func (*MockStorage) ReadReceipts ¶ added in v0.5.3
func (*MockStorage) ReadSnapshot ¶ added in v0.5.3
func (m *MockStorage) ReadSnapshot(hash types.Hash) ([]byte, bool)
func (*MockStorage) ReadTotalDifficulty ¶ added in v0.5.3
func (*MockStorage) ReadTxLookup ¶ added in v0.5.3
func (*MockStorage) WriteCanonicalHash ¶ added in v0.5.3
func (m *MockStorage) WriteCanonicalHash(n uint64, hash types.Hash) error
func (*MockStorage) WriteCanonicalHeader ¶ added in v0.5.3
func (*MockStorage) WriteForks ¶ added in v0.5.3
func (m *MockStorage) WriteForks(forks []types.Hash) error
func (*MockStorage) WriteHeadHash ¶ added in v0.5.3
func (m *MockStorage) WriteHeadHash(h types.Hash) error
func (*MockStorage) WriteHeadNumber ¶ added in v0.5.3
func (m *MockStorage) WriteHeadNumber(n uint64) error
func (*MockStorage) WriteHeader ¶ added in v0.5.3
func (m *MockStorage) WriteHeader(h *types.Header) error
func (*MockStorage) WriteReceipts ¶ added in v0.5.3
func (*MockStorage) WriteSnapshot ¶ added in v0.5.3
func (m *MockStorage) WriteSnapshot(hash types.Hash, blob []byte) error
func (*MockStorage) WriteTotalDifficulty ¶ added in v0.5.3
func (*MockStorage) WriteTxLookup ¶ added in v0.5.3
type PlaceholderStorage ¶ added in v0.5.3
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, error) WriteTotalDifficulty(hash types.Hash, diff *big.Int) error ReadTotalDifficulty(hash types.Hash) (*big.Int, bool) WriteHeader(h *types.Header) error ReadHeader(hash types.Hash) (*types.Header, error) WriteCanonicalHeader(h *types.Header, diff *big.Int) error WriteBody(hash types.Hash, body *types.Body) error ReadBody(hash types.Hash) (*types.Body, error) 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, error) WriteTxLookup(hash types.Hash, blockHash types.Hash) error ReadTxLookup(hash types.Hash) (types.Hash, bool) Close() error }
Storage is a generic blockchain storage