blockdb

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockData = "../block.dat"
)

Directory of block data

Variables

View Source
var (
	// ErrNotExist indicates certain item does not exist in Blockchain database
	ErrNotExist = errors.New("not exist in DB")
	// ErrAlreadyExist indicates certain item already exists in Blockchain database
	ErrAlreadyExist = errors.New("already exist in DB")
)

Functions

This section is empty.

Types

type BlockDB

type BlockDB struct {
	*bolt.DB
}

BlockDB defines the DB interface to read/store/persist blocks

func NewBlockDB

func NewBlockDB(cfg *config.Config) (*BlockDB, bool)

NewBlockDB returns a new BlockDB instance

func (*BlockDB) CheckInBlock

func (db *BlockDB) CheckInBlock(blk []byte, hash []byte, h uint32) error

CheckInBlock checks a block into DB

func (*BlockDB) CheckOutBlock

func (db *BlockDB) CheckOutBlock(hash []byte) (blk []byte, err error)

CheckOutBlock checks a block out of DB

func (*BlockDB) GetBlockHash

func (db *BlockDB) GetBlockHash(height uint32) (hash []byte, err error)

GetBlockHash returns the block hash by height

func (*BlockDB) GetBlockHeight

func (db *BlockDB) GetBlockHeight(hash []byte) (height uint32, err error)

GetBlockHeight returns the block height by hash

func (*BlockDB) Init

func (db *BlockDB) Init() (hash []byte, height uint32, err error)

Init initializes the BlockDB instance

func (*BlockDB) StoreBlockToFile

func (db *BlockDB) StoreBlockToFile(start, end uint32) error

StoreBlockToFile writes block raw data into file

Jump to

Keyboard shortcuts

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