store

package
v0.1.8-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
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) Current

func (s *ChainStore) Current(opts ...types.CallOp) (types.Block, error)

Current gets the current block at the tip of the chain

func (*ChainStore) DB

func (s *ChainStore) DB() elldb.DB

DB gets the database

func (*ChainStore) Delete

func (s *ChainStore) Delete(key []byte, opts ...types.CallOp) error

Delete deletes objects

func (*ChainStore) GetAccount

func (s *ChainStore) GetAccount(address util.String, opts ...types.CallOp) (types.Account, error)

GetAccount gets an account

func (*ChainStore) GetAccounts

func (s *ChainStore) GetAccounts(opts ...types.CallOp) ([]types.Account, error)

GetAccounts gets all accounts

func (*ChainStore) GetBlock

func (s *ChainStore) GetBlock(number uint64, opts ...types.CallOp) (types.Block, error)

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

func (s *ChainStore) GetBlockByHash(hash util.Hash, opts ...types.CallOp) (types.Block, error)

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) GetHeader

func (s *ChainStore) GetHeader(number uint64, opts ...types.CallOp) (types.Header, error)

GetHeader gets the header of the current block in the chain

func (*ChainStore) GetHeaderByHash

func (s *ChainStore) GetHeaderByHash(hash util.Hash, opts ...types.CallOp) (types.Header, error)

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

func (s *ChainStore) PutBlock(block types.Block, opts ...types.CallOp) error

PutBlock adds a block to the store. Returns error if a block with same number exists.

func (*ChainStore) PutMinedBlock

func (s *ChainStore) PutMinedBlock(block types.Block, opts ...types.CallOp) error

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.

Jump to

Keyboard shortcuts

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