ngblocks

package
v0.0.0-...-e87e1d8 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package ngblocks is a store for blocks which contains txs

Index

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 ErrDBNotInit = errors.New("DB not initialized")
View Source
var ErrMalformedGenesisBlock = errors.New("malformed genesis block")
View Source
var ErrPutEmptyBlock = errors.New("putting empty block into the db")

Functions

func GetBlockByHash

func GetBlockByHash(blockBucket *bbolt.Bucket, hash []byte) (*ngtypes.FullBlock, error)

func GetBlockByHeight

func GetBlockByHeight(blockBucket *bbolt.Bucket, height uint64) (*ngtypes.FullBlock, error)

func GetLatestBlock

func GetLatestBlock(blockBucket *bbolt.Bucket) (*ngtypes.FullBlock, error)

func GetLatestHash

func GetLatestHash(blockBucket *bbolt.Bucket) ([]byte, error)

func GetLatestHeight

func GetLatestHeight(blockBucket *bbolt.Bucket) (uint64, error)

func GetOriginBlock

func GetOriginBlock(blockBucket *bbolt.Bucket) (*ngtypes.FullBlock, error)

func GetOriginHash

func GetOriginHash(blockBucket *bbolt.Bucket) ([]byte, error)

func GetOriginHeight

func GetOriginHeight(blockBucket *bbolt.Bucket) (uint64, error)

func GetTxByHash

func GetTxByHash(txBucket *bbolt.Bucket, hash []byte) (*ngtypes.FullTx, error)

func PutNewBlock

func PutNewBlock(blockBucket *bbolt.Bucket, txBucket *bbolt.Bucket, block *ngtypes.FullBlock) error

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

type BlockStore struct {
	*bbolt.DB
	Network ngtypes.Network
}

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 *bbolt.DB, network ngtypes.Network) *BlockStore

Init will do all initialization for the block store.

func (*BlockStore) ForcePutNewBlock

func (store *BlockStore) ForcePutNewBlock(blockBucket *bbolt.Bucket, txBucket *bbolt.Bucket, block *ngtypes.FullBlock) 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.FullBlock) error

Jump to

Keyboard shortcuts

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