Documentation ¶
Index ¶
- Variables
- func TestStorage(t *testing.T, m PlaceholderStorage)
- type Batch
- type BatchWriter
- func (b *BatchWriter) PutBody(hash types.Hash, body *types.Body)
- func (b *BatchWriter) PutCanonicalHash(n uint64, hash types.Hash)
- func (b *BatchWriter) PutCanonicalHeader(h *types.Header, diff *big.Int)
- func (b *BatchWriter) PutForks(forks []types.Hash)
- func (b *BatchWriter) PutHeadHash(h types.Hash)
- func (b *BatchWriter) PutHeadNumber(n uint64)
- func (b *BatchWriter) PutHeader(h *types.Header)
- func (b *BatchWriter) PutReceipts(hash types.Hash, receipts []*types.Receipt)
- func (b *BatchWriter) PutTotalDifficulty(hash types.Hash, diff *big.Int)
- func (b *BatchWriter) PutTxLookup(hash types.Hash, blockHash types.Hash)
- func (b *BatchWriter) WriteBatch() error
- type Factory
- type Forks
- type KV
- type KeyValueStorage
- func (s *KeyValueStorage) Close() error
- func (s *KeyValueStorage) NewBatch() Batch
- 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) ReadTotalDifficulty(hash types.Hash) (*big.Int, bool)
- func (s *KeyValueStorage) ReadTxLookup(hash types.Hash) (types.Hash, bool)
- type MockStorage
- func (m *MockStorage) Close() error
- func (m *MockStorage) HookClose(fn closeDelegate)
- func (m *MockStorage) HookNewBatch(fn newBatchDelegate)
- 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) HookReadTotalDifficulty(fn readTotalDifficultyDelegate)
- func (m *MockStorage) HookReadTxLookup(fn readTxLookupDelegate)
- func (m *MockStorage) NewBatch() Batch
- 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) ReadTotalDifficulty(hash types.Hash) (*big.Int, bool)
- func (m *MockStorage) ReadTxLookup(hash types.Hash) (types.Hash, bool)
- 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 BatchWriter ¶ added in v1.1.0
type BatchWriter struct {
// contains filtered or unexported fields
}
func NewBatchWriter ¶ added in v1.1.0
func NewBatchWriter(storage Storage) *BatchWriter
func (*BatchWriter) PutBody ¶ added in v1.1.0
func (b *BatchWriter) PutBody(hash types.Hash, body *types.Body)
func (*BatchWriter) PutCanonicalHash ¶ added in v1.1.0
func (b *BatchWriter) PutCanonicalHash(n uint64, hash types.Hash)
func (*BatchWriter) PutCanonicalHeader ¶ added in v1.1.0
func (b *BatchWriter) PutCanonicalHeader(h *types.Header, diff *big.Int)
func (*BatchWriter) PutForks ¶ added in v1.1.0
func (b *BatchWriter) PutForks(forks []types.Hash)
func (*BatchWriter) PutHeadHash ¶ added in v1.1.0
func (b *BatchWriter) PutHeadHash(h types.Hash)
func (*BatchWriter) PutHeadNumber ¶ added in v1.1.0
func (b *BatchWriter) PutHeadNumber(n uint64)
func (*BatchWriter) PutHeader ¶ added in v1.1.0
func (b *BatchWriter) PutHeader(h *types.Header)
func (*BatchWriter) PutReceipts ¶ added in v1.1.0
func (b *BatchWriter) PutReceipts(hash types.Hash, receipts []*types.Receipt)
func (*BatchWriter) PutTotalDifficulty ¶ added in v1.1.0
func (b *BatchWriter) PutTotalDifficulty(hash types.Hash, diff *big.Int)
func (*BatchWriter) PutTxLookup ¶ added in v1.1.0
func (b *BatchWriter) PutTxLookup(hash types.Hash, blockHash types.Hash)
func (*BatchWriter) WriteBatch ¶ added in v1.1.0
func (b *BatchWriter) WriteBatch() error
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 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) NewBatch ¶ added in v1.1.0
func (s *KeyValueStorage) NewBatch() Batch
NewBatch creates batch used for write/update/delete operations
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) ReadTotalDifficulty ¶
ReadTotalDifficulty reads the difficulty
func (*KeyValueStorage) ReadTxLookup ¶
ReadTxLookup reads the block hash using the transaction hash
type MockStorage ¶
type MockStorage struct {
// contains filtered or unexported fields
}
func NewMockStorage ¶ added in v0.4.1
func NewMockStorage() *MockStorage
func (*MockStorage) Close ¶ added in v0.4.1
func (m *MockStorage) Close() error
func (*MockStorage) HookClose ¶ added in v0.4.1
func (m *MockStorage) HookClose(fn closeDelegate)
func (*MockStorage) HookNewBatch ¶ added in v1.1.0
func (m *MockStorage) HookNewBatch(fn newBatchDelegate)
func (*MockStorage) HookReadBody ¶ added in v0.4.1
func (m *MockStorage) HookReadBody(fn readBodyDelegate)
func (*MockStorage) HookReadCanonicalHash ¶ added in v0.4.1
func (m *MockStorage) HookReadCanonicalHash(fn readCanonicalHashDelegate)
func (*MockStorage) HookReadForks ¶ added in v0.4.1
func (m *MockStorage) HookReadForks(fn readForksDelegate)
func (*MockStorage) HookReadHeadHash ¶ added in v0.4.1
func (m *MockStorage) HookReadHeadHash(fn readHeadHashDelegate)
func (*MockStorage) HookReadHeadNumber ¶ added in v0.4.1
func (m *MockStorage) HookReadHeadNumber(fn readHeadNumberDelegate)
func (*MockStorage) HookReadHeader ¶ added in v0.4.1
func (m *MockStorage) HookReadHeader(fn readHeaderDelegate)
func (*MockStorage) HookReadReceipts ¶ added in v0.4.1
func (m *MockStorage) HookReadReceipts(fn readReceiptsDelegate)
func (*MockStorage) HookReadTotalDifficulty ¶ added in v0.4.1
func (m *MockStorage) HookReadTotalDifficulty(fn readTotalDifficultyDelegate)
func (*MockStorage) HookReadTxLookup ¶ added in v0.4.1
func (m *MockStorage) HookReadTxLookup(fn readTxLookupDelegate)
func (*MockStorage) NewBatch ¶ added in v1.1.0
func (m *MockStorage) NewBatch() Batch
func (*MockStorage) ReadCanonicalHash ¶ added in v0.4.1
func (m *MockStorage) ReadCanonicalHash(n uint64) (types.Hash, bool)
func (*MockStorage) ReadForks ¶ added in v0.4.1
func (m *MockStorage) ReadForks() ([]types.Hash, error)
func (*MockStorage) ReadHeadHash ¶ added in v0.4.1
func (m *MockStorage) ReadHeadHash() (types.Hash, bool)
func (*MockStorage) ReadHeadNumber ¶ added in v0.4.1
func (m *MockStorage) ReadHeadNumber() (uint64, bool)
func (*MockStorage) ReadHeader ¶ added in v0.4.1
func (*MockStorage) ReadReceipts ¶ added in v0.4.1
func (*MockStorage) ReadTotalDifficulty ¶ added in v0.4.1
func (*MockStorage) ReadTxLookup ¶ added in v0.4.1
type PlaceholderStorage ¶ added in v0.4.1
type Storage ¶
type Storage interface { ReadCanonicalHash(n uint64) (types.Hash, bool) ReadHeadHash() (types.Hash, bool) ReadHeadNumber() (uint64, bool) ReadForks() ([]types.Hash, error) ReadTotalDifficulty(hash types.Hash) (*big.Int, bool) ReadHeader(hash types.Hash) (*types.Header, error) ReadBody(hash types.Hash) (*types.Body, error) ReadReceipts(hash types.Hash) ([]*types.Receipt, error) ReadTxLookup(hash types.Hash) (types.Hash, bool) NewBatch() Batch Close() error }
Storage is a generic blockchain storage