Documentation ¶
Index ¶
- Constants
- type ChainStore
- func (s *ChainStore) CreateAccount(targetBlockNum uint64, account types.Account, opts ...types.CallOp) error
- func (s *ChainStore) Current(opts ...types.CallOp) (types.Block, error)
- func (s *ChainStore) DB() elldb.DB
- func (s *ChainStore) Delete(key []byte, opts ...types.CallOp) error
- func (s *ChainStore) GetAccount(address util.String, opts ...types.CallOp) (types.Account, error)
- func (s *ChainStore) GetAccounts(opts ...types.CallOp) ([]types.Account, error)
- func (s *ChainStore) GetBlock(number uint64, opts ...types.CallOp) (types.Block, error)
- func (s *ChainStore) GetBlockByHash(hash util.Hash, opts ...types.CallOp) (types.Block, error)
- func (s *ChainStore) GetBlockByNumberAndHash(number uint64, hash util.Hash, opts ...types.CallOp) (types.Block, error)
- func (s *ChainStore) GetHeader(number uint64, opts ...types.CallOp) (types.Header, error)
- func (s *ChainStore) GetHeaderByHash(hash util.Hash, opts ...types.CallOp) (types.Header, error)
- func (s *ChainStore) GetTransaction(hash util.Hash, opts ...types.CallOp) (types.Transaction, error)
- func (s *ChainStore) NewTx() (elldb.Tx, error)
- func (s *ChainStore) PutBlock(block types.Block, opts ...types.CallOp) error
- func (s *ChainStore) PutMinedBlock(block types.Block, opts ...types.CallOp) error
- func (s *ChainStore) PutTransactions(txs []types.Transaction, blockNumber uint64, opts ...types.CallOp) error
Constants ¶
const MetadataKey = "meta"
MetadataKey is the key used to store the metadata
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainStore ¶
type ChainStore struct {
// contains filtered or unexported fields
}
ChainStore represents a store that implements the ChainStore interface meant to be used for persisting and retrieving objects for a given chain.
func New ¶
func New(db elldb.DB, chainID util.String) *ChainStore
New creates an instance of the store
func (*ChainStore) CreateAccount ¶
func (s *ChainStore) CreateAccount(targetBlockNum uint64, account types.Account, opts ...types.CallOp) error
CreateAccount creates an account on a target block
func (*ChainStore) Delete ¶
func (s *ChainStore) Delete(key []byte, opts ...types.CallOp) error
Delete deletes objects
func (*ChainStore) GetAccount ¶
GetAccount gets an account
func (*ChainStore) GetAccounts ¶
GetAccounts gets all accounts
func (*ChainStore) GetBlock ¶
GetBlock fetches a block by its block number. If the block number begins with -1, the block with the highest block number is returned.
func (*ChainStore) GetBlockByHash ¶
GetBlockByHash fetches a block by its block hash.
func (*ChainStore) GetBlockByNumberAndHash ¶
func (s *ChainStore) GetBlockByNumberAndHash(number uint64, hash util.Hash, opts ...types.CallOp) (types.Block, error)
GetBlockByNumberAndHash finds by number and hash
func (*ChainStore) GetHeaderByHash ¶
GetHeaderByHash returns the header of a block by searching using its hash
func (*ChainStore) GetTransaction ¶
func (s *ChainStore) GetTransaction(hash util.Hash, opts ...types.CallOp) (types.Transaction, error)
GetTransaction gets a transaction (by hash) belonging to a chain
func (*ChainStore) NewTx ¶
func (s *ChainStore) NewTx() (elldb.Tx, error)
NewTx creates and returns a transaction
func (*ChainStore) PutBlock ¶
PutBlock adds a block to the store. Returns error if a block with same number exists.
func (*ChainStore) PutMinedBlock ¶
PutMinedBlock stores a brief information about a block that was created by the blockchain's coinbase key
func (*ChainStore) PutTransactions ¶
func (s *ChainStore) PutTransactions(txs []types.Transaction, blockNumber uint64, opts ...types.CallOp) error
PutTransactions creates transaction pointers that stores the block numbers where the transactions can be found as opposed to storing the entire transaction. This saves disk space when considering that the block on disk already contains the transaction.