Versions in this module Expand all Collapse all v6 v6.4.0 May 18, 2020 Changes in this version + var BackBlockNum int64 = 128 + var BackwardBlockNum int64 = 16 + var ErrBlockHeightDiscontinuous = errors.New("ErrBlockHeightDiscontinuous") + var ErrCurHeightMoreThanEndHeight = errors.New("ErrCurHeightMoreThanEndHeight") + var ErrIsOrphan = errors.New("ErrIsOrphan") + var ErrIsSideChain = errors.New("ErrIsSideChain") + var FutureBlockDelayTime int64 = 1 + var HashToParaSeqPrefix = []byte("HashToParaSeq:") + var HashToSeqPrefix = []byte("HashToSeq:") + var InitBlockNum int64 = 10240 + var LastParaSequence = []byte("LastParaSequence") + var LastSequence = []byte("LastSequence") + var MaxRollBlockNum int64 = 10000 + var MaxSeqCB int64 = 20 + var ReduceHeight = MaxRollBlockNum + var SafetyReduceHeight = ReduceHeight * 3 / 2 + func GetLocalDBKeyList() [][]byte + func IsRecordFaultErr(err error) bool + func LoadBlockStoreHeight(db dbm.DB) (int64, error) + func NewBodyTable(kvdb dbm.KV) *table.Table + func NewHeaderTable(kvdb dbm.KV) *table.Table + func NewParaTxTable(kvdb dbm.KV) *table.Table + func NewReceiptTable(kvdb dbm.KV) *table.Table + type BestPeerInfo struct + Hash []byte + Height int64 + IsBestChain bool + Peer *PeerInfo + ReqFlag bool + Td *big.Int + type BlockCache struct + func NewBlockCache(param *types.Chain33Config, defCacheSize int64) *BlockCache + func (chain *BlockCache) CheckcacheBlock(height int64) (block *types.BlockDetail) + func (chain *BlockCache) GetCacheBlock(hash []byte) (block *types.BlockDetail) + func (chain *BlockCache) HasCacheTx(hash []byte) bool + type BlockChain struct + DefCacheSize int64 + MaxFetchBlockNum int64 + TimeoutSeconds int64 + func New(cfg *types.Chain33Config) *BlockChain + func (b *BlockChain) LoadBlockByHash(hash []byte) (block *types.BlockDetail, err error) + func (b *BlockChain) ProcessBlock(broadcast bool, block *types.BlockDetail, pid string, addBlock bool, ...) (*types.BlockDetail, bool, bool, error) + func (b *BlockChain) ProcessDelParaChainBlock(broadcast bool, blockdetail *types.BlockDetail, pid string, sequence int64) (*types.BlockDetail, bool, bool, error) + func (chain *BlockChain) AddFaultPeer(faultpeer *FaultPeerInfo) + func (chain *BlockChain) CheckBestChain(isFirst bool) + func (chain *BlockChain) CheckBestChainProc(headers *types.Headers, pid string) + func (chain *BlockChain) CheckHeightNoIncrease() + func (chain *BlockChain) CheckTipBlockHash() + func (chain *BlockChain) Close() + func (chain *BlockChain) DefaultDownLoadInfo() + func (chain *BlockChain) DelLastTempBlockHeight() + func (chain *BlockChain) DownLoadTimeOutProc(height int64) + func (chain *BlockChain) ExportBlock(title, dbPath string, startHeight int64) error + func (chain *BlockChain) ExportBlockProc(title string, dir string, startHeight int64) + func (chain *BlockChain) FastDownLoadBlocks() + func (chain *BlockChain) FetchBlock(start int64, end int64, pid []string, syncOrfork bool) (err error) + func (chain *BlockChain) FetchBlockHeaders(start int64, end int64, pid string) (err error) + func (chain *BlockChain) FetchPeerList() + func (chain *BlockChain) GetBestChainPeer(pid string) *BestPeerInfo + func (chain *BlockChain) GetBestChainPids() []string + func (chain *BlockChain) GetBlock(height int64) (block *types.BlockDetail, err error) + func (chain *BlockChain) GetBlockByHashes(hashes [][]byte) (respblocks *types.BlockDetails, err error) + func (chain *BlockChain) GetBlockHeight() int64 + func (chain *BlockChain) GetBlockSequences(requestblock *types.ReqBlocks) (*types.BlockSequences, error) + func (chain *BlockChain) GetDB() dbm.DB + func (chain *BlockChain) GetDownLoadInfo() *DownLoadInfo + func (chain *BlockChain) GetDownloadSyncStatus() bool + func (chain *BlockChain) GetDuplicateTxHashList(txhashlist *types.TxHashList) (duptxhashlist *types.TxHashList, err error) + func (chain *BlockChain) GetFaultPeer(pid string) *FaultPeerInfo + func (chain *BlockChain) GetLastBlockMainSequence(msg *queue.Message) + func (chain *BlockChain) GetLastTempBlockHeight() int64 + func (chain *BlockChain) GetMainSeqByHash(msg *queue.Message) + func (chain *BlockChain) GetMaxPeerInfo() *PeerInfo + func (chain *BlockChain) GetNtpClockSyncStatus() bool + func (chain *BlockChain) GetOrphanPool() *OrphanPool + func (chain *BlockChain) GetParaTxByHeight(req *types.ReqParaTxByHeight) (*types.ParaTxDetails, error) + func (chain *BlockChain) GetParaTxByTitle(seq *types.ReqParaTxByTitle) (*types.ParaTxDetails, error) + func (chain *BlockChain) GetPeerInfo(pid string) *PeerInfo + func (chain *BlockChain) GetPeerMaxBlkHeight() int64 + func (chain *BlockChain) GetPeers() PeerInfoList + func (chain *BlockChain) GetPeersMap() map[string]bool + func (chain *BlockChain) GetRcvLastCastBlkHeight() int64 + func (chain *BlockChain) GetStore() *BlockStore + func (chain *BlockChain) GetTxResultFromDb(txhash []byte) (tx *types.TxResult, err error) + func (chain *BlockChain) GetValueByKey(keys *types.LocalDBGet) *types.LocalReplyValue + func (chain *BlockChain) GetsynBlkHeight() int64 + func (chain *BlockChain) HasTx(txhash []byte, onlyquerycache bool) (has bool, err error) + func (chain *BlockChain) ImportBlock(filename, dbPath string) error + func (chain *BlockChain) ImportBlockProc(filename string, dir string) + func (chain *BlockChain) InitBlockChain() + func (chain *BlockChain) InitCache(height int64) + func (chain *BlockChain) InitDownLoadInfo(StartHeight int64, EndHeight int64, pids []string) + func (chain *BlockChain) InitIndexAndBestView() + func (chain *BlockChain) InitReduceLocalDB(height int64) + func (chain *BlockChain) IsCaughtUp() bool + func (chain *BlockChain) IsErrExecBlock(height int64, hash []byte) (bool, error) + func (chain *BlockChain) IsFaultPeer(pid string) bool + func (chain *BlockChain) LoadParaTxByHeight(height int64, title string, count, direction int32) (*types.HeightParas, error) + func (chain *BlockChain) LoadParaTxByTitle(req *types.ReqHeightByTitle) (*types.ReplyHeightByTitle, error) + func (chain *BlockChain) NeedReExec(meta *types.UpgradeMeta) bool + func (chain *BlockChain) NeedRollback(curHeight, rollHeight int64) bool + func (chain *BlockChain) OnChainTimeout(height int64) bool + func (chain *BlockChain) ProcAddBlockHeadersMsg(headers *types.Headers, pid string) error + func (chain *BlockChain) ProcAddBlockMsg(broadcast bool, blockdetail *types.BlockDetail, pid string) (*types.BlockDetail, error) + func (chain *BlockChain) ProcAddBlockSeqCB(cb *types.BlockSeqCB) ([]*types.Sequence, error) + func (chain *BlockChain) ProcAddParaChainBlockMsg(broadcast bool, ParaChainblockdetail *types.ParaChainBlockDetail, pid string) (*types.BlockDetail, error) + func (chain *BlockChain) ProcBlockHeader(headers *types.Headers, peerid string) error + func (chain *BlockChain) ProcBlockHeaders(headers *types.Headers, pid string) error + func (chain *BlockChain) ProcDelParaChainBlockMsg(broadcast bool, ParaChainblockdetail *types.ParaChainBlockDetail, pid string) (err error) + func (chain *BlockChain) ProcDownLoadBlocks(StartHeight int64, EndHeight int64, pids []string) + func (chain *BlockChain) ProcFutureBlocks() + func (chain *BlockChain) ProcGetAddrOverview(addr *types.ReqAddr) (*types.AddrOverview, error) + func (chain *BlockChain) ProcGetBlockByHashMsg(hash []byte) (respblock *types.BlockDetail, err error) + func (chain *BlockChain) ProcGetBlockDetailsMsg(requestblock *types.ReqBlocks) (respblocks *types.BlockDetails, err error) + func (chain *BlockChain) ProcGetBlockHash(height *types.ReqInt) (*types.ReplyHash, error) + func (chain *BlockChain) ProcGetBlockOverview(ReqHash *types.ReqHash) (*types.BlockOverview, error) + func (chain *BlockChain) ProcGetHeadersMsg(requestblock *types.ReqBlocks) (respheaders *types.Headers, err error) + func (chain *BlockChain) ProcGetLastBlockMsg() (respblock *types.Block, err error) + func (chain *BlockChain) ProcGetLastHeaderMsg() (*types.Header, error) + func (chain *BlockChain) ProcGetMainSeqByHash(hash []byte) (int64, error) + func (chain *BlockChain) ProcGetSeqByHash(hash []byte) (int64, error) + func (chain *BlockChain) ProcGetSeqCBLastNum(name string) int64 + func (chain *BlockChain) ProcGetTransactionByAddr(addr *types.ReqAddr) (*types.ReplyTxInfos, error) + func (chain *BlockChain) ProcGetTransactionByHashes(hashs [][]byte) (TxDetails *types.TransactionDetails, err error) + func (chain *BlockChain) ProcListBlockSeqCB() (*types.BlockSeqCBs, error) + func (chain *BlockChain) ProcQueryTxMsg(txhash []byte) (proof *types.TransactionDetail, err error) + func (chain *BlockChain) ProcRecvMsg() + func (chain *BlockChain) ReExecBlock(startHeight, curHeight int64) + func (chain *BlockChain) ReadBlockByHeight(height int64) (*types.Block, error) + func (chain *BlockChain) ReadBlockToExec(height int64, isNewStart bool) + func (chain *BlockChain) RecordFaultPeer(pid string, height int64, hash []byte, err error) + func (chain *BlockChain) RecoveryFaultPeer() + func (chain *BlockChain) ReduceChain() + func (chain *BlockChain) ReduceLocalDB() + func (chain *BlockChain) RemoveFaultPeer(pid string) + func (chain *BlockChain) ReqDownLoadBlocks() + func (chain *BlockChain) Rollback() + func (chain *BlockChain) Rollbackblock() + func (chain *BlockChain) SendAddBlockEvent(block *types.BlockDetail) (err error) + func (chain *BlockChain) SendBlockBroadcast(block *types.BlockDetail) + func (chain *BlockChain) SendDelBlockEvent(block *types.BlockDetail) (err error) + func (chain *BlockChain) SetQueueClient(client queue.Client) + func (chain *BlockChain) SetValueByKey(kvs *types.LocalDBSet) error + func (chain *BlockChain) SynBlocksFromPeers() + func (chain *BlockChain) SynRoutine() + func (chain *BlockChain) TryReduceLocalDB(flagHeight int64, rangeHeight int64) (newHeight int64) + func (chain *BlockChain) UpdateDownLoadPids() + func (chain *BlockChain) UpdateDownLoadStartHeight(StartHeight int64) + func (chain *BlockChain) UpdateDownloadSyncStatus(Sync bool) + func (chain *BlockChain) UpdateFaultPeer(pid string, reqFlag bool) + func (chain *BlockChain) UpdateNtpClockSyncStatus(Sync bool) + func (chain *BlockChain) UpdateRcvCastBlkHeight(height int64) + func (chain *BlockChain) UpdateRoutine() + func (chain *BlockChain) UpdatesynBlkHeight(height int64) + func (chain *BlockChain) Upgrade() + func (chain *BlockChain) UpgradeChain() + func (chain *BlockChain) UpgradePlugin() + func (chain *BlockChain) UpgradeStore() + func (chain *BlockChain) Wait() + func (chain *BlockChain) WriteBlockToDbTemp(block *types.Block, lastHeightSave bool) error + type BlockOnChain struct + Height int64 + OnChainTime int64 + type BlockStore struct + func NewBlockStore(chain *BlockChain, db dbm.DB, client queue.Client) *BlockStore + func (bs *BlockStore) AddTxs(storeBatch dbm.Batch, blockDetail *types.BlockDetail) error + func (bs *BlockStore) BlockdetailToBlockBody(blockdetail *types.BlockDetail) *types.BlockBody + func (bs *BlockStore) CheckSequenceStatus(recordSequence bool) int + func (bs *BlockStore) CreateSequences(batchSize int64) + func (bs *BlockStore) DelBlock(storeBatch dbm.Batch, blockdetail *types.BlockDetail, sequence int64) (int64, error) + func (bs *BlockStore) DelTxs(storeBatch dbm.Batch, blockDetail *types.BlockDetail) error + func (bs *BlockStore) Get(keys *types.LocalDBGet) *types.LocalReplyValue + func (bs *BlockStore) GetBlockByMainSequence(sequence int64) (*types.BlockSequence, error) + func (bs *BlockStore) GetBlockHashByHeight(height int64) ([]byte, error) + func (bs *BlockStore) GetBlockHeaderByHash(hash []byte) (*types.Header, error) + func (bs *BlockStore) GetBlockHeaderByHeight(height int64) (*types.Header, error) + func (bs *BlockStore) GetBlockSequence(Sequence int64) (*types.BlockSequence, error) + func (bs *BlockStore) GetDbVersion() int64 + func (bs *BlockStore) GetHeightByBlockHash(hash []byte) (int64, error) + func (bs *BlockStore) GetKey(key []byte) ([]byte, error) + func (bs *BlockStore) GetMainSequenceByHash(hash []byte) (int64, error) + func (bs *BlockStore) GetSequenceByHash(hash []byte) (int64, error) + func (bs *BlockStore) GetStoreUpgradeMeta() (*types.UpgradeMeta, error) + func (bs *BlockStore) GetTdByBlockHash(hash []byte) (*big.Int, error) + func (bs *BlockStore) GetTx(hash []byte) (*types.TxResult, error) + func (bs *BlockStore) GetUpgradeMeta() (*types.UpgradeMeta, error) + func (bs *BlockStore) HasTx(key []byte) (bool, error) + func (bs *BlockStore) Height() int64 + func (bs *BlockStore) LastBlock() *types.Block + func (bs *BlockStore) LastHeader() *types.Header + func (bs *BlockStore) List(prefix []byte) ([][]byte, error) + func (bs *BlockStore) LoadBlockByHash(hash []byte) (*types.BlockDetail, error) + func (bs *BlockStore) LoadBlockByHeight(height int64) (*types.BlockDetail, error) + func (bs *BlockStore) LoadBlockByMainSequence(sequence int64) (*types.BlockDetail, int, error) + func (bs *BlockStore) LoadBlockBySequence(Sequence int64) (*types.BlockDetail, int, error) + func (bs *BlockStore) LoadBlockLastMainSequence() (int64, error) + func (bs *BlockStore) LoadBlockLastSequence() (int64, error) + func (bs *BlockStore) NewBatch(sync bool) dbm.Batch + func (bs *BlockStore) PrefixCount(prefix []byte) int64 + func (bs *BlockStore) SaveBlock(storeBatch dbm.Batch, blockdetail *types.BlockDetail, sequence int64) (int64, error) + func (bs *BlockStore) SaveTdByBlockHash(storeBatch dbm.Batch, hash []byte, td *big.Int) error + func (bs *BlockStore) Set(key, value []byte) error + func (bs *BlockStore) SetConsensusPara(kvs *types.LocalDBSet) error + func (bs *BlockStore) SetDbVersion(versionNo int64) error + func (bs *BlockStore) SetStoreUpgradeMeta(meta *types.UpgradeMeta) error + func (bs *BlockStore) SetSync(key, value []byte) error + func (bs *BlockStore) SetUpgradeMeta(meta *types.UpgradeMeta) error + func (bs *BlockStore) UpdateHeight() + func (bs *BlockStore) UpdateHeight2(height int64) + func (bs *BlockStore) UpdateLastBlock(hash []byte) + func (bs *BlockStore) UpdateLastBlock2(block *types.Block) + type BodyRow struct + func NewBodyRow() *BodyRow + func (body *BodyRow) CreateRow() *table.Row + func (body *BodyRow) Get(key string) ([]byte, error) + func (body *BodyRow) SetPayload(data types.Message) error + type CommonStore interface + GetKey func(key []byte) ([]byte, error) + List func(prefix []byte) ([][]byte, error) + PrefixCount func(prefix []byte) int64 + Set func(key, value []byte) error + SetSync func(key, value []byte) error + type DownLoadInfo struct + EndHeight int64 + Pids []string + StartHeight int64 + type ErrCountInfo struct + Count int64 + Height int64 + type FaultPeerInfo struct + ErrInfo error + FaultHash []byte + FaultHeight int64 + Peer *PeerInfo + ReqFlag bool + type HeaderRow struct + func NewHeaderRow() *HeaderRow + func (header *HeaderRow) CreateRow() *table.Row + func (header *HeaderRow) Get(key string) ([]byte, error) + func (header *HeaderRow) SetPayload(data types.Message) error + type OrphanPool struct + func NewOrphanPool(param *types.Chain33Config) *OrphanPool + func (op *OrphanPool) AddOrphanBlock(broadcast bool, block *types.Block, pid string, sequence int64) + func (op *OrphanPool) GetOrphanRoot(hash []byte) []byte + func (op *OrphanPool) IsKnownOrphan(hash []byte) bool + func (op *OrphanPool) ProcessOrphans(hash []byte, b *BlockChain) error + func (op *OrphanPool) RemoveOrphanBlock(orphan *orphanBlock) + func (op *OrphanPool) RemoveOrphanBlock2(block *types.Block, expiration time.Time, broadcast bool, pid string, ...) + func (op *OrphanPool) RemoveOrphanBlockByHash(hash []byte) + type ParaTxRow struct + func NewParaTxRow() *ParaTxRow + func (paratx *ParaTxRow) CreateRow() *table.Row + func (paratx *ParaTxRow) Get(key string) ([]byte, error) + func (paratx *ParaTxRow) SetPayload(data types.Message) error + type PeerInfo struct + Hash []byte + Height int64 + Name string + ParentHash []byte + type PeerInfoList []*PeerInfo + func (list PeerInfoList) Len() int + func (list PeerInfoList) Less(i, j int) bool + func (list PeerInfoList) Swap(i, j int) + type PushSeqStore1 struct + func (push *PushSeqStore1) AddCallback(cb *types.BlockSeqCB) error + func (push *PushSeqStore1) CallbackCount() int64 + func (push *PushSeqStore1) CallbackExist(name string) bool + func (push *PushSeqStore1) GetLastPushSeq(name string) int64 + func (push *PushSeqStore1) ListCB() (cbs []*types.BlockSeqCB, err error) + func (push *PushSeqStore1) SetLastPushSeq(name []byte, num int64) error + func (push *PushSeqStore1) SetLastPushSeqSync(name []byte, num int64) error + type PushSeqStrore interface + type PushService interface + Add func() + Get func() + List func() + type PushService1 struct + func (push *PushService1) AddCallback(pushseq PushWorkNotify, cb *types.BlockSeqCB) ([]*types.Sequence, error) + func (push *PushService1) GetLastPushSeq(name string) int64 + func (push *PushService1) ListCallback() (*types.BlockSeqCBs, error) + type PushWorkNotify interface + AddTask func(cb *types.BlockSeqCB) + UpdateSeq func(seq int64) + type Query struct + func NewQuery(db dbm.DB, qclient queue.Client, stateHash []byte) *Query + func (q *Query) Query(driver string, funcname string, param types.Message) (types.Message, error) + type ReceiptRow struct + func NewReceiptRow() *ReceiptRow + func (recpt *ReceiptRow) CreateRow() *table.Row + func (recpt *ReceiptRow) Get(key string) ([]byte, error) + func (recpt *ReceiptRow) SetPayload(data types.Message) error + type SequenceStore interface + GetBlockHeaderByHash func(hash []byte) (*types.Header, error) + GetBlockSequence func(seq int64) (*types.BlockSequence, error) + GetSequenceByHash func(hash []byte) (int64, error) + LastHeader func() *types.Header + LoadBlockBySequence func(seq int64) (*types.BlockDetail, int, error) + LoadBlockLastSequence func() (int64, error) + type Task struct + func (t *Task) Cancel() error + func (t *Task) Done(height int64) + func (t *Task) InProgress() bool + func (t *Task) Start(start, end int64, cb func(), timeoutcb func(height int64)) error + func (t *Task) TimerReset(timeout time.Duration) + func (t *Task) TimerStop() Other modules containing this package github.com/33cn/chain33