Documentation ¶
Overview ¶
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) CheckBindingIndex(rebuild bool) error
- func (db *ChainDb) CheckScriptHashUsed(scriptHash []byte) (bool, error)
- func (db *ChainDb) CheckStakingTxIndex(rebuild bool) error
- func (db *ChainDb) CheckTxIndex_1_1_0() error
- func (db *ChainDb) Close() error
- func (db *ChainDb) Commit(hash wire.Hash) error
- func (db *ChainDb) CountByPrefix(prefix string) (num, size int)
- func (db *ChainDb) CountByPrefixForNew(prefix string) (num, size int)
- func (db *ChainDb) DeleteAddrIndex(hash *wire.Hash, height uint64) error
- func (db *ChainDb) DeleteBlock(hash *wire.Hash) error
- func (db *ChainDb) ExistsFaultPk(sha *wire.Hash) (bool, error)
- func (db *ChainDb) ExistsPunishment(pk interfaces.PublicKey) (bool, error)
- func (db *ChainDb) ExistsSha(sha *wire.Hash) (bool, error)
- func (db *ChainDb) ExistsTxSha(txsha *wire.Hash) (bool, error)
- func (db *ChainDb) FetchAddrIndexTip() (*wire.Hash, uint64, error)
- func (db *ChainDb) FetchAllFaultPks() ([]*wire.FaultPubKey, []uint64, error)
- func (db *ChainDb) FetchAllPunishment() ([]*wire.FaultPubKey, error)
- func (db *ChainDb) FetchBlockBySha(sha *wire.Hash) (blk *massutil.Block, err error)
- func (db *ChainDb) FetchBlockHeaderBySha(sha *wire.Hash) (bh *wire.BlockHeader, err error)
- func (db *ChainDb) FetchBlockHeightBySha(sha *wire.Hash) (uint64, error)
- func (db *ChainDb) FetchBlockLocByHeight(height uint64) (*database.BlockLoc, error)
- func (db *ChainDb) FetchBlockShaByHeight(height uint64) (sha *wire.Hash, err error)
- func (db *ChainDb) FetchExpiredStakingTxListByHeight(expiredHeight uint64) (database.StakingNodes, error)
- func (db *ChainDb) FetchFaultPkBySha(sha *wire.Hash) (fpk *wire.FaultPubKey, height uint64, err error)
- func (db *ChainDb) FetchFaultPkListByHeight(blkHeight uint64) ([]*wire.FaultPubKey, error)
- func (db *ChainDb) FetchHeightRange(startHeight, endHeight uint64) ([]wire.Hash, error)
- func (db *ChainDb) FetchLastFullySpentTxBeforeHeight(txsha *wire.Hash, height uint64) (msgtx *wire.MsgTx, blkHeight uint64, blksha *wire.Hash, err error)
- func (db *ChainDb) FetchMinedBlocks(pubKey interfaces.PublicKey) ([]uint64, error)
- func (db *ChainDb) FetchOldBinding(scriptHash []byte) ([]*database.BindingTxReply, error)
- func (db *ChainDb) FetchScriptHashRelatedTx(scriptHashes [][]byte, startBlock, stopBlock uint64) (map[uint64][]*wire.TxLoc, error)
- func (db *ChainDb) FetchStakingRank(height uint64, onlyOnList bool) ([]database.Rank, error)
- func (db *ChainDb) FetchStakingTxMap() (database.StakingNodes, error)
- func (db *ChainDb) FetchTxByFileLoc(blkLoc *database.BlockLoc, txLoc *wire.TxLoc) (*wire.MsgTx, error)
- func (db *ChainDb) FetchTxByLoc(blkHeight 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) FetchUnSpentTxByShaList(txShaList []*wire.Hash) []*database.TxReply
- func (db *ChainDb) FetchUnexpiredStakingRank(height uint64, onlyOnList bool) ([]database.Rank, error)
- func (db *ChainDb) ForEach(prefix string, callback func(k, v []byte) error) error
- func (db *ChainDb) Get(key []byte) ([]byte, error)
- func (db *ChainDb) GetAllStaking() (database.StakingNodes, database.StakingNodes, error)
- func (db *ChainDb) GetBlkLocByHeight(height uint64) (sha *wire.Hash, fileNo uint32, offset int64, size int64, err error)
- func (db *ChainDb) GetUnspentTxData(txsha *wire.Hash) (uint64, int, int, error)
- func (db *ChainDb) InitByGenesisBlock(block *massutil.Block) error
- func (db *ChainDb) InsertPunishment(fpk *wire.FaultPubKey) error
- func (db *ChainDb) NewestSha() (rSha *wire.Hash, rBlkHeight 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 *massutil.Block) error
- func (db *ChainDb) Sync() error
- func (db *ChainDb) TestExportDbEntries() map[string][]byte
- 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") )
var ( PUBLICKEYLENGTH_MASS = 33 PUBLICKEYLENGTH_CHIA = 48 )
var (
ErrCheckStakingDeletion = errors.New("failed to delete staking")
)
Functions ¶
This section is empty.
Types ¶
type ChainDb ¶
type ChainDb struct {
// contains filtered or unexported fields
}
ChainDb holds internal state for databse.
func (*ChainDb) CheckBindingIndex ¶
func (*ChainDb) CheckScriptHashUsed ¶
func (*ChainDb) CheckStakingTxIndex ¶
func (*ChainDb) CheckTxIndex_1_1_0 ¶
func (*ChainDb) CountByPrefix ¶
func (*ChainDb) CountByPrefixForNew ¶
func (*ChainDb) DeleteAddrIndex ¶
func (*ChainDb) ExistsFaultPk ¶
ExistsFaultPk - check whether a specific PubKey has been banned, returns true if banned
func (*ChainDb) ExistsPunishment ¶
func (db *ChainDb) ExistsPunishment(pk interfaces.PublicKey) (bool, error)
func (*ChainDb) ExistsSha ¶
ExistsSha looks up the given block hash returns true if it is present in the database.
func (*ChainDb) ExistsTxSha ¶
ExistsTxSha returns if the given tx sha exists in the database
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) FetchAllFaultPks ¶
func (db *ChainDb) FetchAllFaultPks() ([]*wire.FaultPubKey, []uint64, error)
func (*ChainDb) FetchAllPunishment ¶
func (db *ChainDb) FetchAllPunishment() ([]*wire.FaultPubKey, error)
func (*ChainDb) FetchBlockBySha ¶
FetchBlockBySha - return a massutil 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 ¶
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) FetchFaultPkBySha ¶
func (db *ChainDb) FetchFaultPkBySha(sha *wire.Hash) (fpk *wire.FaultPubKey, height uint64, err error)
FetchFaultPkBySha - return a banned pubKey along with corresponding testimony
func (*ChainDb) FetchFaultPkListByHeight ¶
func (db *ChainDb) FetchFaultPkListByHeight(blkHeight uint64) ([]*wire.FaultPubKey, error)
FetchFaultPkListByHeight - return newly banned PubKey list on specific height
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, blkHeight uint64, blksha *wire.Hash, err error)
Returns database.ErrTxShaMissing if txsha not exist
func (*ChainDb) FetchMinedBlocks ¶
func (db *ChainDb) FetchMinedBlocks(pubKey interfaces.PublicKey) ([]uint64, error)
func (*ChainDb) FetchOldBinding ¶
func (db *ChainDb) FetchOldBinding(scriptHash []byte) ([]*database.BindingTxReply, error)
func (*ChainDb) FetchScriptHashRelatedTx ¶
func (db *ChainDb) FetchScriptHashRelatedTx( scriptHashes [][]byte, startBlock, stopBlock uint64, ) (map[uint64][]*wire.TxLoc, error)
from start to stop-1
func (*ChainDb) FetchStakingRank ¶
FetchStakingRank returns staking rank at any height. This function may be slow.
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) 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) GetAllStaking ¶
func (db *ChainDb) GetAllStaking() (database.StakingNodes, database.StakingNodes, error)
func (*ChainDb) GetBlkLocByHeight ¶
func (*ChainDb) GetUnspentTxData ¶
func (*ChainDb) InitByGenesisBlock ¶
func (*ChainDb) InsertPunishment ¶
func (db *ChainDb) InsertPunishment(fpk *wire.FaultPubKey) error
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.
func (*ChainDb) TestExportDbEntries ¶
For testing purpose