Documentation
¶
Overview ¶
Package ngblocks is a store for blocks which contains txs
Index ¶
- Variables
- func GetBlockByHash(txn *badger.Txn, hash []byte) (*ngtypes.Block, error)
- func GetBlockByHeight(txn *badger.Txn, height uint64) (*ngtypes.Block, error)
- func GetLatestBlock(txn *badger.Txn) (*ngtypes.Block, error)
- func GetLatestHash(txn *badger.Txn) ([]byte, error)
- func GetLatestHeight(txn *badger.Txn) (uint64, error)
- func GetOriginBlock(txn *badger.Txn) (*ngtypes.Block, error)
- func GetOriginHash(txn *badger.Txn) ([]byte, error)
- func GetOriginHeight(txn *badger.Txn) (uint64, error)
- func GetTxByHash(txn *badger.Txn, hash []byte) (*ngtypes.Tx, error)
- func PutNewBlock(txn *badger.Txn, block *ngtypes.Block) error
- type BlockStore
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBlockHeightConflict = errors.New("already has a block on the same height") ErrPrevBlockNotExist = errors.New("prev block does not exist") )
View Source
var ErrNoTxInHash = errors.New("cannot find tx by the hash")
View Source
var ErrPutEmptyBlock = errors.New("putting empty block into the db")
Functions ¶
func GetBlockByHeight ¶
func GetLatestBlock ¶
func GetLatestHash ¶
func GetLatestHeight ¶
func GetOriginBlock ¶
func GetOriginHash ¶
func GetOriginHeight ¶
func PutNewBlock ¶
PutNewBlock puts a new block into db and updates the tags. should check block before putting dev should continue upgrading the state after PutNewBlock
Types ¶
type BlockStore ¶
BlockStore managers a badger DB, which stores vaults and blocks and some helper tags for managing. TODO: Add DAG support to extend the capacity of store initialize with genesis blocks first, then load the origin in bootstrap process
func Init ¶
func Init(db *badger.DB, network ngtypes.Network) *BlockStore
Init will do all initialization for the block store.
func (*BlockStore) ForcePutNewBlock ¶
func (store *BlockStore) ForcePutNewBlock(txn *badger.Txn, block *ngtypes.Block) error
ForcePutNewBlock puts a block into db regardless of local store check should check block self before putting
func (*BlockStore) InitFromCheckpoint ¶
func (store *BlockStore) InitFromCheckpoint(block *ngtypes.Block) error
Click to show internal directories.
Click to hide internal directories.