Documentation ¶
Overview ¶
LSN (log sequence number) This file is only used to check data correctness for 1.1.0
Index ¶
- Constants
- Variables
- type ChainDb
- func (db *ChainDb) Batch(index int) *LBatch
- func (db *ChainDb) CheckScriptHashUsed(scriptHash []byte) (bool, error)
- func (db *ChainDb) CheckTxIndex_1_1_0() error
- func (db *ChainDb) Close() error
- func (db *ChainDb) Commit(blockSha wire.Hash) error
- func (db *ChainDb) DeleteAddrIndex(hash *wire.Hash, height uint64) error
- func (db *ChainDb) DeleteBlock(blockSha *wire.Hash) error
- func (db *ChainDb) ExistsBlockSha(sha *wire.Hash) (bool, error)
- func (db *ChainDb) ExistsFaultPubKey(sha *wire.Hash) (bool, error)
- func (db *ChainDb) ExistsPunishment(pk *pocec.PublicKey) (bool, error)
- func (db *ChainDb) ExistsTxSha(txSha *wire.Hash) (bool, error)
- func (db *ChainDb) ExportDbEntries() map[string][]byte
- func (db *ChainDb) FetchAddrIndexTip() (*wire.Hash, uint64, error)
- func (db *ChainDb) FetchAllFaultPubKeys() ([]*wire.FaultPubKey, []uint64, error)
- func (db *ChainDb) FetchAllPunishment() ([]*wire.FaultPubKey, error)
- func (db *ChainDb) FetchBlockBySha(sha *wire.Hash) (block *chainutil.Block, err error)
- func (db *ChainDb) FetchBlockHeaderBySha(sha *wire.Hash) (bh *wire.BlockHeader, err error)
- func (db *ChainDb) FetchBlockHeightBySha(blockSha *wire.Hash) (uint64, error)
- func (db *ChainDb) FetchBlockLocByHeight(height uint64) (*database.BlockLoc, error)
- func (db *ChainDb) FetchBlockShaByHeight(height uint64) (rawBlockSha *wire.Hash, err error)
- func (db *ChainDb) FetchExpiredStakingTxListByHeight(expiredHeight uint64) (database.StakingNodes, error)
- func (db *ChainDb) FetchFaultPubKeyBySha(sha *wire.Hash) (fpk *wire.FaultPubKey, height uint64, err error)
- func (db *ChainDb) FetchFaultPubKeyListByHeight(blockHeight uint64) ([]*wire.FaultPubKey, error)
- func (db *ChainDb) FetchGovernConfigData(id uint16, height uint64, includeShadow bool) ([]*database.GovernConfigData, error)
- func (db *ChainDb) FetchHeightRange(startHeight, endHeight uint64) ([]wire.Hash, error)
- func (db *ChainDb) FetchLastFullySpentTxBeforeHeight(txSha *wire.Hash, height uint64) (msgTx *wire.MsgTx, blockHeight uint64, blockSha *wire.Hash, err error)
- func (db *ChainDb) FetchMinedBlocks(pubKey *pocec.PublicKey) ([]uint64, error)
- func (db *ChainDb) FetchScriptHashRelatedBindingTx(scriptHash []byte, chainParams *config.Params) ([]*database.BindingTxReply, error)
- func (db *ChainDb) FetchScriptHashRelatedTx(scriptHashes [][]byte, startBlock, stopBlock uint64) (map[uint64][]*wire.TxLoc, error)
- func (db *ChainDb) FetchStakingAwardedRecordByTime(queryTime uint64) ([]database.StakingAwardedRecord, error)
- func (db *ChainDb) FetchStakingRank(height uint64, onlyOnList bool) ([]database.Rank, error)
- func (db *ChainDb) FetchStakingStakingRewardInfo(height uint64) (*database.StakingRewardInfo, error)
- func (db *ChainDb) FetchStakingTxMap() (database.StakingNodes, error)
- func (db *ChainDb) FetchTxByFileLoc(blockLocation *database.BlockLoc, txLoc *wire.TxLoc) (*wire.MsgTx, error)
- func (db *ChainDb) FetchTxByLoc(blockHeight uint64, txOff int, txLen int) (*wire.MsgTx, error)
- func (db *ChainDb) FetchTxBySha(txSha *wire.Hash) ([]*database.TxReply, error)
- func (db *ChainDb) FetchTxByShaList(txShaList []*wire.Hash) []*database.TxReply
- func (db *ChainDb) FetchUnSpentStaking(txShaList []*wire.Hash) []*database.TxReply
- func (db *ChainDb) FetchUnSpentStakingPoolTxOutByHeight(startHeight uint64, endHeight uint64) ([]*database.TxOutReply, error)
- func (db *ChainDb) FetchUnSpentTxByShaList(txShaList []*wire.Hash) []*database.TxReply
- func (db *ChainDb) FetchUnexpiredStakingRank(height uint64, onlyOnList bool) ([]database.Rank, error)
- func (db *ChainDb) GetPubkeyBLHeightRecord(publicKey *pocec.PublicKey) ([]*database.BLHeight, error)
- func (db *ChainDb) GetUnspentTxData(txSha *wire.Hash) (uint64, int, int, error)
- func (db *ChainDb) IndexPubKeyBLHeight(rebuild bool) error
- func (db *ChainDb) InitByGenesisBlock(block *chainutil.Block) error
- func (db *ChainDb) InsertGovernConfig(id uint16, height, activeHeight uint64, shadow bool, txSha *wire.Hash, ...) error
- func (db *ChainDb) InsertPunishment(fpk *wire.FaultPubKey) error
- func (db *ChainDb) IsTxOutSpent(txSha *wire.Hash, index int) (bool, error)
- func (db *ChainDb) NewestSha() (rawBlockSha *wire.Hash, rawBlockHeight uint64, err error)
- func (db *ChainDb) Rollback()
- func (db *ChainDb) RollbackClose() error
- func (db *ChainDb) SubmitAddrIndex(hash *wire.Hash, height uint64, addrIndexData *database.AddrIndexData) error
- func (db *ChainDb) SubmitBlock(block *chainutil.Block) error
- func (db *ChainDb) Sync() error
- func (db *ChainDb) Upgrade_1_1_0() error
- type LBatch
Constants ¶
const (
UnknownHeight = math.MaxUint64
)
Variables ¶
var ( ErrUpgradeHeight = errors.New("upgrade error: height") ErrUpgradeBlockHash = errors.New("upgrade error: block hash") ErrUpgradeFileNumber = errors.New("upgrade error: file number") )
var ( ErrWrongScriptHashLength = errors.New("length of script hash error") ErrBindingIndexBroken = errors.New("binding transaction index was broken") ErrIncorrectDbData = errors.New("incorrect db data") ErrCheckStakingDuplicated = errors.New("duplicated staking") // errors for submit.go ErrPreBatchNotReady = errors.New("previous batch is not ready") ErrCommitHashNotEqual = errors.New("commit hash is not equal to batch hash") ErrCommitBatchNotReady = errors.New("commit batch is not ready") // errors for binding transaction index ErrWrongBindingTxIndexLen = errors.New("length of binding tx index is invalid") ErrWrongBindingTxIndexPrefix = errors.New("prefix of binding tx index is invalid") ErrWrongBindingShIndexLen = errors.New("length of binding sh index is invalid") ErrWrongBindingShIndexPrefix = errors.New("prefix of binding sh index is invalid") ErrWrongBindingTxSpentIndexLen = errors.New("length of binding tx spent index is invalid") ErrWrongBindingTxSpentIndexPrefix = errors.New("prefix of binding tx spent index is invalid") // for disk file ErrInvalidBlockFileMeta = errors.New("invalid blockfile meta") ErrIncorrectValueLength = errors.New("incorrect value length") ErrIncorrectValue = errors.New("incorrect value") )
Functions ¶
This section is empty.
Types ¶
type ChainDb ¶
type ChainDb struct {
// contains filtered or unexported fields
}
ChainDb holds internal state for database.
func (*ChainDb) CheckScriptHashUsed ¶
func (*ChainDb) CheckTxIndex_1_1_0 ¶
func (*ChainDb) DeleteAddrIndex ¶
func (*ChainDb) ExistsBlockSha ¶
ExistsSha looks up the given block hash returns true if it is present in the database.
func (*ChainDb) ExistsFaultPubKey ¶
ExistsFaultPk - check whether a specific PubKey has been banned, returns true if banned
func (*ChainDb) ExistsPunishment ¶
func (*ChainDb) ExistsTxSha ¶
ExistsTxSha returns if the given tx sha exists in the database
func (*ChainDb) ExportDbEntries ¶
For testing purpose
func (*ChainDb) FetchAddrIndexTip ¶
FetchAddrIndexTip returns the hash and block height of the most recent block whose transactions have been indexed by address. It will return ErrAddrIndexDoesNotExist along with a zero hash, and UnknownHeight if the addrIndex hasn't yet been built up.
func (*ChainDb) FetchAllFaultPubKeys ¶
func (db *ChainDb) FetchAllFaultPubKeys() ([]*wire.FaultPubKey, []uint64, error)
func (*ChainDb) FetchAllPunishment ¶
func (db *ChainDb) FetchAllPunishment() ([]*wire.FaultPubKey, error)
func (*ChainDb) FetchBlockBySha ¶
FetchBlockBySha - return a Block
func (*ChainDb) FetchBlockHeaderBySha ¶
FetchBlockHeaderBySha - return a Hash
func (*ChainDb) FetchBlockHeightBySha ¶
FetchBlockHeightBySha returns the block height for the given hash. This is part of the database.Db interface implementation.
func (*ChainDb) FetchBlockLocByHeight ¶
FetchBlockLocByHeight
func (*ChainDb) FetchBlockShaByHeight ¶
FetchBlockShaByHeight returns a block hash based on its height in the block chain.
func (*ChainDb) FetchExpiredStakingTxListByHeight ¶
func (db *ChainDb) FetchExpiredStakingTxListByHeight(expiredHeight uint64) (database.StakingNodes, error)
func (*ChainDb) FetchFaultPubKeyBySha ¶
func (db *ChainDb) FetchFaultPubKeyBySha(sha *wire.Hash) (fpk *wire.FaultPubKey, height uint64, err error)
FetchFaultPkBySha - return a banned pubKey along with corresponding testimony
func (*ChainDb) FetchFaultPubKeyListByHeight ¶
func (db *ChainDb) FetchFaultPubKeyListByHeight(blockHeight uint64) ([]*wire.FaultPubKey, error)
FetchFaultPkListByHeight - return newly banned PubKey list on specific height
func (*ChainDb) FetchGovernConfigData ¶
func (db *ChainDb) FetchGovernConfigData(id uint16, height uint64, includeShadow bool) ([]*database.GovernConfigData, error)
FetchGovernConfigData fetch all config
func (*ChainDb) FetchHeightRange ¶
FetchHeightRange looks up a range of blocks by the start and ending heights. Fetch is inclusive of the start height and exclusive of the ending height.
func (*ChainDb) FetchLastFullySpentTxBeforeHeight ¶
func (db *ChainDb) FetchLastFullySpentTxBeforeHeight(txSha *wire.Hash, height uint64) (msgTx *wire.MsgTx, blockHeight uint64, blockSha *wire.Hash, err error)
Returns database.ErrTxShaMissing if txsha not exist
func (*ChainDb) FetchMinedBlocks ¶
func (*ChainDb) FetchScriptHashRelatedBindingTx ¶
func (*ChainDb) FetchScriptHashRelatedTx ¶
func (db *ChainDb) FetchScriptHashRelatedTx(scriptHashes [][]byte, startBlock, stopBlock uint64) (map[uint64][]*wire.TxLoc, error)
from start to stop-1
func (*ChainDb) FetchStakingAwardedRecordByTime ¶
func (db *ChainDb) FetchStakingAwardedRecordByTime(queryTime uint64) ([]database.StakingAwardedRecord, error)
FetchStakingAwardedRecordByTime +-----------+-----------+--------------+ +-----------+ | prefix(3) | day(8) | TxId(32) | ->| timestamp | +-----------+-----------+--------------+ +-----------+
func (*ChainDb) FetchStakingRank ¶
FetchStakingRank returns staking rank at any height. This function may be slow.
func (*ChainDb) FetchStakingStakingRewardInfo ¶
func (db *ChainDb) FetchStakingStakingRewardInfo(height uint64) (*database.StakingRewardInfo, error)
func (*ChainDb) FetchStakingTxMap ¶
func (db *ChainDb) FetchStakingTxMap() (database.StakingNodes, error)
func (*ChainDb) FetchTxByFileLoc ¶
func (*ChainDb) FetchTxByLoc ¶
func (*ChainDb) FetchTxBySha ¶
FetchTxBySha returns some data for the given Tx Sha. Be careful, main chain may be revoked during invocation.
func (*ChainDb) FetchTxByShaList ¶
FetchTxByShaList returns the most recent tx of the name fully spent or not
func (*ChainDb) FetchUnSpentStaking ¶
func (*ChainDb) FetchUnSpentStakingPoolTxOutByHeight ¶
func (*ChainDb) FetchUnSpentTxByShaList ¶
FetchUnSpentTxByShaList given a array of Hash, look up the transactions and return them in a TxReply array.
func (*ChainDb) FetchUnexpiredStakingRank ¶
func (db *ChainDb) FetchUnexpiredStakingRank(height uint64, onlyOnList bool) ([]database.Rank, error)
FetchUnexpiredStakingRank returns only currently unexpired staking rank at target height. This function is for mining and validating block.
func (*ChainDb) GetPubkeyBLHeightRecord ¶
func (*ChainDb) GetUnspentTxData ¶
func (*ChainDb) IndexPubKeyBLHeight ¶
transition code that will be removed soon
func (*ChainDb) InitByGenesisBlock ¶
func (*ChainDb) InsertGovernConfig ¶
func (*ChainDb) InsertPunishment ¶
func (db *ChainDb) InsertPunishment(fpk *wire.FaultPubKey) error
func (*ChainDb) IsTxOutSpent ¶
IsTxOutSpent index --> 32 bits +------------------------------------------------------ | index | spent flag offset ( 8 bits ) | +-----------------------------------------------------+
txSpent index(offset) --> spent
+-----------------------------------------------------+ | 1 | 0 | | +-----------------------------------------------------+
func (*ChainDb) NewestSha ¶
NewestSha returns the hash and block height of the most recent (end) block of the block chain. It will return the zero hash, UnknownHeight for the block height, and no error (nil) if there are not any blocks in the database yet.
func (*ChainDb) RollbackClose ¶
RollbackClose this is part of the database.Db interface and should discard recent changes to the db and the close the db. This currently just does a clean shutdown.
func (*ChainDb) SubmitAddrIndex ¶
func (*ChainDb) Sync ¶
Sync verifies that the database is coherent on disk, and no outstanding transactions are in flight.