Documentation
¶
Index ¶
- Constants
- func RegisterBlockchainMessages()
- type BalanceRecordStore
- type BlockPool
- func (pool *BlockPool) AddBlock(peerID string, block *types.Block, blockSize int)
- func (pool *BlockPool) GetStatus() (height uint64, numPending int32, lenRequesters int)
- func (pool *BlockPool) IsCaughtUp() bool
- func (pool *BlockPool) MaxPeerHeight() uint64
- func (pool *BlockPool) MockCaughtUp(mock bool) bool
- func (pool *BlockPool) NeverCaughtUp(keepFastSync bool) bool
- func (pool *BlockPool) OnReset() error
- func (pool *BlockPool) OnStart() error
- func (pool *BlockPool) OnStop()
- func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block)
- func (pool *BlockPool) PopRequest()
- func (pool *BlockPool) RedoRequest(height uint64) string
- func (pool *BlockPool) RemovePeer(peerID string)
- func (pool *BlockPool) SetPeerHeight(peerID string, height uint64)
- type BlockRequest
- type BlockStore
- func (bs *BlockStore) DeleteHistoricalData(keepLatestBlocks uint64)
- func (bs *BlockStore) GetDB() dbm.DB
- func (bs *BlockStore) GetHeader(height uint64) *types.Header
- func (bs *BlockStore) GetOutputKey(amount *big.Int, index uint64, includeCommitment bool) types.UTXOOutputData
- func (bs *BlockStore) GetOutputKeys(amounts []*big.Int, offsets []uint64, outputs []types.UTXOOutputData, ...)
- func (bs *BlockStore) GetReceipts(height uint64) *types.Receipts
- func (bs *BlockStore) GetTransactionReceipt(hash common.Hash) (*types.Receipt, common.Hash, uint64, uint64)
- func (bs *BlockStore) GetTx(hash common.Hash) (types.Tx, *types.TxEntry)
- func (bs *BlockStore) GetTxFromBlock(block *types.Block, hash common.Hash) types.Tx
- func (bs *BlockStore) HaveTxKeyimgAsSpent(keyImage lktypes.Key) bool
- func (bs *BlockStore) Height() uint64
- func (bs *BlockStore) IsTxSpendTimeUnlocked(unlockTime uint64) bool
- func (bs *BlockStore) LoadBlock(height uint64) *types.Block
- func (bs *BlockStore) LoadBlockAndMeta(height uint64) (*types.Block, *types.BlockMeta)
- func (bs *BlockStore) LoadBlockByHash(hash common.Hash) *types.Block
- func (bs *BlockStore) LoadBlockCommit(height uint64) *types.Commit
- func (bs *BlockStore) LoadBlockMeta(height uint64) *types.BlockMeta
- func (bs *BlockStore) LoadBlockMetaByHash(hash common.Hash) *types.BlockMeta
- func (bs *BlockStore) LoadBlockPart(height uint64, index int) *types.Part
- func (bs *BlockStore) LoadInitHeight() (uint64, error)
- func (bs *BlockStore) LoadSeenCommit(height uint64) *types.Commit
- func (bs *BlockStore) LoadTxsResult(height uint64) (*types.TxsResult, error)
- func (bs *BlockStore) RollBackOneBlock()
- func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit, ...)
- func (bs *BlockStore) SaveInitHeight(height uint64)
- func (bs *BlockStore) SetCrossState(crossState txmgr.CrossState)
- type BlockStoreStateJSON
- type BlockchainMessage
- type BlockchainReactor
- func (bcR *BlockchainReactor) AddPeer(peer p2p.Peer)
- func (bcR *BlockchainReactor) BroadcastStatusRequest() error
- func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
- func (bcR *BlockchainReactor) KeepFastSync(keepFastSync bool)
- func (bcR *BlockchainReactor) OnStart() error
- func (bcR *BlockchainReactor) OnStop()
- func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
- func (bcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})
- func (bcR *BlockchainReactor) RestartFastSync(status cs.NewStatus) error
- func (bcR *BlockchainReactor) SetLogger(l log.Logger)
- func (bcR *BlockchainReactor) StopFastSync() bool
Constants ¶
const ( // BlockchainChannel is a channel for blocks and status updates BlockchainChannel = byte(0x40) )
Variables ¶
This section is empty.
Functions ¶
func RegisterBlockchainMessages ¶
func RegisterBlockchainMessages()
Types ¶
type BalanceRecordStore ¶
type BalanceRecordStore struct {
// contains filtered or unexported fields
}
func NewBalanceRecordStore ¶
func NewBalanceRecordStore(db dbm.DB, openFlag bool) *BalanceRecordStore
func (*BalanceRecordStore) Get ¶
func (b *BalanceRecordStore) Get(blockHeight uint64) *types.BlockBalanceRecords
func (*BalanceRecordStore) Save ¶
func (b *BalanceRecordStore) Save(blockHeight uint64, bbr *types.BlockBalanceRecords)
type BlockPool ¶
type BlockPool struct { cmn.BaseService // contains filtered or unexported fields }
func NewBlockPool ¶
func NewBlockPool(start uint64, requestsCh chan<- BlockRequest, errorsCh chan<- peerError) *BlockPool
func (*BlockPool) IsCaughtUp ¶
TODO: relax conditions, prevent abuse.
func (*BlockPool) MaxPeerHeight ¶
MaxPeerHeight returns the highest height reported by a peer.
func (*BlockPool) MockCaughtUp ¶
func (*BlockPool) NeverCaughtUp ¶
func (*BlockPool) PeekTwoBlocks ¶
We need to see the second block's Commit to validate the first block. So we peek two blocks at a time. The caller will verify the commit.
func (*BlockPool) PopRequest ¶
func (pool *BlockPool) PopRequest()
Pop the first block at pool.height It must have been validated by 'second'.Commit from PeekTwoBlocks().
func (*BlockPool) RedoRequest ¶
Invalidates the block at pool.height, Remove the peer and redo request from others. Returns the ID of the removed peer.
func (*BlockPool) RemovePeer ¶
func (*BlockPool) SetPeerHeight ¶
Sets the peer's alleged blockchain height.
type BlockRequest ¶
type BlockStore ¶
type BlockStore struct {
// contains filtered or unexported fields
}
BlockStore is a simple low level store for blocks.
There are three types of information stored:
- BlockMeta: Meta information about each block
- Block part: Parts of each block, aggregated w/ PartSet
- Commit: The commit part of each block, for gossiping precommit votes
Currently the precommit signatures are duplicated in the Block parts as well as the Commit. In the future this may change, perhaps by moving the Commit data outside the Block. (TODO)
// NOTE: BlockStore methods will panic if they encounter errors // deserializing loaded data, indicating probable corruption on disk.
func NewBlockStore ¶
func NewBlockStore(db dbm.DB) *BlockStore
NewBlockStore returns a new BlockStore with the given DB, initialized to the last height that was committed to the DB.
func (*BlockStore) DeleteHistoricalData ¶
func (bs *BlockStore) DeleteHistoricalData(keepLatestBlocks uint64)
func (*BlockStore) GetHeader ¶
func (bs *BlockStore) GetHeader(height uint64) *types.Header
GetHeader returns the header for the given height. If not found for the given height, it returns nil.
func (*BlockStore) GetOutputKey ¶
func (bs *BlockStore) GetOutputKey(amount *big.Int, index uint64, includeCommitment bool) types.UTXOOutputData
func (*BlockStore) GetOutputKeys ¶
func (bs *BlockStore) GetOutputKeys(amounts []*big.Int, offsets []uint64, outputs []types.UTXOOutputData, allowPartial bool)
func (*BlockStore) GetReceipts ¶
func (bs *BlockStore) GetReceipts(height uint64) *types.Receipts
GetReceipts return all the transaction receipts belonging to a block.
func (*BlockStore) GetTransactionReceipt ¶
func (*BlockStore) GetTxFromBlock ¶
GetTxFromBlock iterator Txs from block to find tx with hash.
func (*BlockStore) HaveTxKeyimgAsSpent ¶
func (bs *BlockStore) HaveTxKeyimgAsSpent(keyImage lktypes.Key) bool
func (*BlockStore) Height ¶
func (bs *BlockStore) Height() uint64
Height returns the last known contiguous block height.
func (*BlockStore) IsTxSpendTimeUnlocked ¶
func (bs *BlockStore) IsTxSpendTimeUnlocked(unlockTime uint64) bool
func (*BlockStore) LoadBlock ¶
func (bs *BlockStore) LoadBlock(height uint64) *types.Block
LoadBlock returns the block with the given height. If no block is found for that height, it returns nil.
func (*BlockStore) LoadBlockAndMeta ¶
func (*BlockStore) LoadBlockByHash ¶
func (bs *BlockStore) LoadBlockByHash(hash common.Hash) *types.Block
LoadBlock returns the block with the given hash. If no block is found for that hash, it returns nil.
func (*BlockStore) LoadBlockCommit ¶
func (bs *BlockStore) LoadBlockCommit(height uint64) *types.Commit
LoadBlockCommit returns the Commit for the given height. This commit consists of the +2/3 and other Precommit-votes for block at `height`, and it comes from the block.LastCommit for `height+1`. If no commit is found for the given height, it returns nil.
func (*BlockStore) LoadBlockMeta ¶
func (bs *BlockStore) LoadBlockMeta(height uint64) *types.BlockMeta
LoadBlockMeta returns the BlockMeta for the given height. If no block is found for the given height, it returns nil.
func (*BlockStore) LoadBlockMetaByHash ¶
func (bs *BlockStore) LoadBlockMetaByHash(hash common.Hash) *types.BlockMeta
LoadBlockMeta returns the BlockMeta for the given hash. If no block is found for the given hash, it returns nil.
func (*BlockStore) LoadBlockPart ¶
func (bs *BlockStore) LoadBlockPart(height uint64, index int) *types.Part
LoadBlockPart returns the Part at the given index from the block at the given height. If no part is found for the given height and index, it returns nil.
func (*BlockStore) LoadInitHeight ¶ added in v0.1.1
func (bs *BlockStore) LoadInitHeight() (uint64, error)
func (*BlockStore) LoadSeenCommit ¶
func (bs *BlockStore) LoadSeenCommit(height uint64) *types.Commit
LoadSeenCommit returns the locally seen Commit for the given height. This is useful when we've seen a commit, but there has not yet been a new block at `height + 1` that includes this commit in its block.LastCommit.
func (*BlockStore) LoadTxsResult ¶
func (bs *BlockStore) LoadTxsResult(height uint64) (*types.TxsResult, error)
LoadTxsResult returns the process result of transactions for the given height.
func (*BlockStore) RollBackOneBlock ¶
func (bs *BlockStore) RollBackOneBlock()
func (*BlockStore) SaveBlock ¶
func (bs *BlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit, receipts *types.Receipts, txsResult *types.TxsResult)
SaveBlock persists the given block, blockParts, and seenCommit to the underlying db. blockParts: Must be parts of the block seenCommit: The +2/3 precommits that were seen which committed at height.
If all the nodes restart after committing a block, we need this to reload the precommits to catch-up nodes to the most recent height. Otherwise they'd stall at H-1.
func (*BlockStore) SaveInitHeight ¶ added in v0.1.1
func (bs *BlockStore) SaveInitHeight(height uint64)
func (*BlockStore) SetCrossState ¶
func (bs *BlockStore) SetCrossState(crossState txmgr.CrossState)
SetCrossState set crossState to crossState.
type BlockStoreStateJSON ¶
type BlockStoreStateJSON struct {
Height uint64 `json:"height"`
}
func LoadBlockStoreStateJSON ¶
func LoadBlockStoreStateJSON(db dbm.DB) BlockStoreStateJSON
LoadBlockStoreStateJSON returns the BlockStoreStateJSON as loaded from disk. If no BlockStoreStateJSON was previously persisted, it returns the zero value.
func (BlockStoreStateJSON) Save ¶
func (bsj BlockStoreStateJSON) Save(db dbm.DB)
Save persists the blockStore state to the database as JSON.
type BlockchainMessage ¶
type BlockchainMessage interface{}
BlockchainMessage is a generic message for this reactor.
type BlockchainReactor ¶
type BlockchainReactor struct { p2p.BaseReactor // contains filtered or unexported fields }
BlockchainReactor handles long-term catchup syncing.
func NewBlockchainReactor ¶
func NewBlockchainReactor(status cs.NewStatus, blockExec *cs.BlockExecutor, app cs.BlockChainApp, fastSync bool, p2pmanager p2p.P2PManager) *BlockchainReactor
NewBlockchainReactor returns new reactor instance.
func (*BlockchainReactor) AddPeer ¶
func (bcR *BlockchainReactor) AddPeer(peer p2p.Peer)
AddPeer implements Reactor by sending our status to peer.
func (*BlockchainReactor) BroadcastStatusRequest ¶
func (bcR *BlockchainReactor) BroadcastStatusRequest() error
BroadcastStatusRequest broadcasts current height.
func (*BlockchainReactor) GetChannels ¶
func (bcR *BlockchainReactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements Reactor
func (*BlockchainReactor) KeepFastSync ¶
func (bcR *BlockchainReactor) KeepFastSync(keepFastSync bool)
func (*BlockchainReactor) OnStart ¶
func (bcR *BlockchainReactor) OnStart() error
OnStart implements cmn.Service.
func (*BlockchainReactor) OnStop ¶
func (bcR *BlockchainReactor) OnStop()
OnStop implements cmn.Service.
func (*BlockchainReactor) Receive ¶
func (bcR *BlockchainReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte)
Receive implements Reactor by handling 4 types of messages (look below).
func (*BlockchainReactor) RemovePeer ¶
func (bcR *BlockchainReactor) RemovePeer(peer p2p.Peer, reason interface{})
RemovePeer implements Reactor by removing peer from the pool.
func (*BlockchainReactor) RestartFastSync ¶
func (bcR *BlockchainReactor) RestartFastSync(status cs.NewStatus) error
Restart switches from consensus mode to fastSync mode.
func (*BlockchainReactor) SetLogger ¶
func (bcR *BlockchainReactor) SetLogger(l log.Logger)
SetLogger implements cmn.Service by setting the logger on reactor and pool.
func (*BlockchainReactor) StopFastSync ¶
func (bcR *BlockchainReactor) StopFastSync() bool