db

package
v0.0.0-...-694c140 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//! Unused.
	BLOCK_VALID_UNKNOWN = 0

	//! Parsed, version ok, hash satisfies claimed PoW, 1 <= vtx count <= max, timestamp not in future
	BLOCK_VALID_HEADER = 1

	//! All parent headers found, difficulty matches, timestamp >= median previous, checkpoint. Implies all parents
	//! are also at least TREE.
	BLOCK_VALID_TREE = 2

	/**
	 * Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid, no duplicate txids,
	 * sigops, size, merkle root. Implies all parents are at least TREE but not necessarily TRANSACTIONS. When all
	 * parent blocks also have TRANSACTIONS, CBlockIndex::nChainTx will be set.
	 */
	BLOCK_VALID_TRANSACTIONS = 3

	//! Outputs do not overspend inputs, no double spends, coinbase output ok, no immature coinbase spends, BIP30.
	//! Implies all parents are also at least CHAIN.
	BLOCK_VALID_CHAIN = 4

	//! Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
	BLOCK_VALID_SCRIPTS = 5

	//! All validity bits.
	BLOCK_VALID_MASK = BLOCK_VALID_HEADER | BLOCK_VALID_TREE | BLOCK_VALID_TRANSACTIONS |
		BLOCK_VALID_CHAIN | BLOCK_VALID_SCRIPTS

	BLOCK_HAVE_DATA = 8  //!< full block available in blk*.dat
	BLOCK_HAVE_UNDO = 16 //!< undo data available in rev*.dat
	BLOCK_HAVE_MASK = BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO

	BLOCK_FAILED_VALID = 32 //!< stage after last reached validness failed
	BLOCK_FAILED_CHILD = 64 //!< descends from failed block
	BLOCK_FAILED_MASK  = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD

	BLOCK_OPT_WITNESS = 128 //!< block data in blk*.data was received with a witness-enforcing client
)

Variables

This section is empty.

Functions

func GetBestBlock

func GetBestBlock(chainstateDb *ChainstateDb) ([]byte, error)

func GetFlag

func GetFlag(indexDb *IndexDb, name []byte) (bool, error)

func GetLastBlockFileNumberUsed

func GetLastBlockFileNumberUsed(indexDb *IndexDb) (uint32, error)

func GetReindexing

func GetReindexing(indexDb *IndexDb) (bool, error)

Types

type BlockIndexRecord

type BlockIndexRecord struct {
	Version        int32
	Height         int32
	Status         uint32
	NTx            uint32
	NFile          int32
	NDataPos       uint32
	NUndoPos       uint32
	HashPrev       blockchainparser.Hash256
	HashMerkleRoot blockchainparser.Hash256
	NTime          time.Time
	NBits          uint32
	NNonce         uint32
}

func GetBlockIndexRecord

func GetBlockIndexRecord(indexDb *IndexDb, blockHash []byte) (*BlockIndexRecord, error)

func GetBlockIndexRecordByBigEndianHex

func GetBlockIndexRecordByBigEndianHex(indexDb *IndexDb, blockHash string) (*BlockIndexRecord, error)

func GetBlockIndexRecordByHex

func GetBlockIndexRecordByHex(indexDb *IndexDb, blockHash string) (*BlockIndexRecord, error)

func NewBlockIndexRecordFromBytes

func NewBlockIndexRecordFromBytes(b []byte) *BlockIndexRecord

type ChainstateDb

type ChainstateDb struct {
	*leveldb.DB
}

func OpenChainstateDb

func OpenChainstateDb(blockchainDataDir string) (*ChainstateDb, error)

type DataBuf

type DataBuf struct {
	// contains filtered or unexported fields
}

TODO: Improve this to use Buffer interface

func NewDataBuf

func NewDataBuf(b []byte) *DataBuf

func (*DataBuf) Reset

func (buf *DataBuf) Reset()

func (*DataBuf) Seek

func (buf *DataBuf) Seek(pos uint64)

func (*DataBuf) Shift16bit

func (buf *DataBuf) Shift16bit() uint16

func (*DataBuf) Shift32bit

func (buf *DataBuf) Shift32bit() int32

func (*DataBuf) Shift64bit

func (buf *DataBuf) Shift64bit() int64

func (*DataBuf) ShiftByte

func (buf *DataBuf) ShiftByte() byte

func (*DataBuf) ShiftBytes

func (buf *DataBuf) ShiftBytes(length uint64) []byte

func (*DataBuf) ShiftU32bit

func (buf *DataBuf) ShiftU32bit() uint32

func (*DataBuf) ShiftU64bit

func (buf *DataBuf) ShiftU64bit() uint64

func (*DataBuf) ShiftVarint

func (buf *DataBuf) ShiftVarint() uint64

type FileInfoRecord

type FileInfoRecord struct {
	NumOfBlocks uint32
	Size        uint32
	UndoSize    uint32
	HeightFirst uint32
	HeightLast  uint32
	TimeFirst   time.Time
	TimeLast    time.Time
}

func GetFileInfoRecord

func GetFileInfoRecord(indexDb *IndexDb, number uint32) (*FileInfoRecord, error)

func NewFileInfoRecordFromBytes

func NewFileInfoRecordFromBytes(b []byte) *FileInfoRecord

type IndexDb

type IndexDb struct {
	*leveldb.DB
}

func OpenIndexDb

func OpenIndexDb(blockchainDataDir string) (*IndexDb, error)

type TxIndexRecord

type TxIndexRecord struct {
	NFile     int32
	NDataPos  uint32
	NTxOffset uint32
}

func GetTxIndexRecord

func GetTxIndexRecord(indexDb *IndexDb, txHash []byte) (*TxIndexRecord, error)

func GetTxIndexRecordByBigEndianHex

func GetTxIndexRecordByBigEndianHex(indexDb *IndexDb, txHash string) (*TxIndexRecord, error)

func GetTxIndexRecordByHex

func GetTxIndexRecordByHex(indexDb *IndexDb, txHash string) (*TxIndexRecord, error)

func NewTxIndexRecordFromBytes

func NewTxIndexRecordFromBytes(b []byte) *TxIndexRecord

Jump to

Keyboard shortcuts

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