Documentation ¶
Index ¶
- Constants
- Variables
- func CheckBlockDigests(block *commonPb.Block, txHashes [][]byte, hashType string, log protocol.Logger) error
- func CheckPreBlock(block *commonPb.Block, lastBlock *commonPb.Block, err error, ...) error
- func CheckVacuumBlock(block *commonPb.Block, consensusType consensus.ConsensusType) error
- func ClearProposeRepeatTimerMap()
- func DeserializeTxBatchInfo(data []byte) (*commonPb.TxBatchInfo, error)
- func FinalizeBlock(block *commonPb.Block, txRWSetMap map[string]*commonPb.TxRWSet, ...) error
- func GetBatchIds(block *commonpb.Block) ([]string, []uint32, error)
- func GetProposerId(ac protocol.AccessControlProvider, netService protocol.NetService, ...) (string, error)
- func GetTurboBlock(block, turboBlock *commonPb.Block, logger protocol.Logger) *commonPb.Block
- func IfExitInSameBranch(height uint64, txId string, proposalCache protocol.ProposalCache, ...) (bool, error)
- func IfOpenConsensusMessageTurbo(chainConf protocol.ChainConf) bool
- func IntegersContains(array []int, val int) bool
- func IsBlockHashValid(block *commonPb.Block, hashType string) error
- func IsDagHashValid(block *commonPb.Block, hashType string) error
- func IsHeightValid(block *commonPb.Block, currentHeight uint64) error
- func IsMerkleRootValid(block *commonPb.Block, txHashes [][]byte, hashType string) error
- func IsPreHashValid(block *commonPb.Block, preHash []byte) error
- func IsRWSetHashValid(block *commonPb.Block, hashType string) error
- func IsTxCountValid(block *commonPb.Block) error
- func IsTxDuplicate(txs []*commonPb.Transaction) (duplicate bool, duplicateTxs []string)
- func IsTxRWSetValid(block *commonpb.Block, tx *commonpb.Transaction, rwSet *commonpb.TxRWSet, ...) error
- func IsTxRequestValid(tx *commonpb.Transaction, txInPool *commonpb.Transaction) error
- func NewBlockCommitter(config BlockCommitterConfig, log protocol.Logger) (protocol.BlockCommitter, error)
- func NotifyChainConf(block *commonpb.Block, chainConf protocol.ChainConf) (err error)
- func RecoverBlock(block *commonPb.Block, mode protocol.VerifyMode, chainConf protocol.ChainConf, ...) (*commonPb.Block, []string, error)
- func RetryAndRemoveTxs(txPool protocol.TxPool, txsRetry []*commonPb.Transaction, ...)
- func SerializeTxBatchInfo(batchIds []string, txs []*commonPb.Transaction, ...) ([]byte, error)
- func TxVerifyResultsMerge(resultTasks map[int]VerifyBlockBatch, ...) ([][]byte, []*commonpb.Transaction, error)
- func ValidateTx(txsRet map[string]*commonpb.Transaction, tx *commonpb.Transaction, ...) error
- func ValidateTxRules(filter protocol.TxFilter, txs []*commonpb.Transaction) (removeTxs []*commonpb.Transaction, remainTxs []*commonpb.Transaction)
- func VerifyHeight(height uint64, ledgerCache protocol.LedgerCache) error
- func VerifyTxResult(tx *commonpb.Transaction, result *commonpb.Result) error
- type BlockBuilder
- type BlockBuilderConf
- type BlockCommitterConfig
- type BlockCommitterImpl
- type CommitBlock
- type KVStoreHelper
- type ReentrantLocks
- type RwSetVerifyFailTx
- type SQLStoreHelper
- type VerifierBlock
- func (vb *VerifierBlock) FetchLastBlock(block *commonPb.Block) (*commonPb.Block, error)
- func (v *VerifierBlock) SetTxScheduler(txScheduler protocol.TxScheduler)
- func (vb *VerifierBlock) ValidateBlock(block, lastBlock *commonPb.Block, hashType string, timeLasts map[string]int64, ...) (map[string]*commonPb.TxRWSet, map[string][]*commonPb.ContractEvent, ...)
- func (vb *VerifierBlock) ValidateBlockWithRWSets(block, lastBlock *commonPb.Block, hashType string, timeLasts map[string]int64, ...) (map[string][]*commonPb.ContractEvent, map[string]int64, *RwSetVerifyFailTx, ...)
- type VerifierBlockConf
- type VerifierTx
- type VerifierTxConfig
- type VerifyBlockBatch
- type VerifyStat
Constants ¶
const ( DEFAULTDURATION = 1000 // default proposal duration, millis seconds //blockSig:%d,vm:%d,txVerify:%d,txRoot:%d BlockSig = "blockSig" VM = "vm" TxVerify = "txVerify" TxRoot = "txRoot" QuickSyncVerifyMode = uint8(1) // quick sync verify mode NormalVerifyMode = uint8(0) // normal verify mode DEFAULTTIMEOUT = 5000 )
const LOCKED = "LOCKED" // LOCKED mark
Variables ¶
var (
ProposeRepeatTimerMap sync.Map
)
var TxPoolType string
Functions ¶
func CheckBlockDigests ¶
func CheckPreBlock ¶
func CheckPreBlock(block *commonPb.Block, lastBlock *commonPb.Block, err error, lastBlockHash []byte, proposedHeight uint64) error
nolint: staticcheck
func CheckVacuumBlock ¶
func CheckVacuumBlock(block *commonPb.Block, consensusType consensus.ConsensusType) error
func ClearProposeRepeatTimerMap ¶
func ClearProposeRepeatTimerMap()
func DeserializeTxBatchInfo ¶
func DeserializeTxBatchInfo(data []byte) (*commonPb.TxBatchInfo, error)
func FinalizeBlock ¶
func GetProposerId ¶
func GetProposerId( ac protocol.AccessControlProvider, netService protocol.NetService, proposer *accesscontrol.Participant) (string, error)
func GetTurboBlock ¶
func IfExitInSameBranch ¶
func IfExitInSameBranch(height uint64, txId string, proposalCache protocol.ProposalCache, preBlockHash []byte) ( bool, error)
判断相同分支上是否存在交易重复(防止双花)
func IntegersContains ¶
func IsBlockHashValid ¶
IsBlockHashValid to check if block hash equals with result calculated from block
func IsDagHashValid ¶
IsDagHashValid to check if block dag equals with simulated block dag
func IsHeightValid ¶
IsHeightValid to check if block height is valid
func IsMerkleRootValid ¶
IsMerkleRootValid to check if block merkle root equals with simulated merkle root
func IsPreHashValid ¶
IsPreHashValid to check if block.preHash equals with last block hash
func IsRWSetHashValid ¶
IsRWSetHashValid to check if read write set is valid
func IsTxCountValid ¶
IsTxCountValid to check if txcount in block is valid
func IsTxDuplicate ¶
func IsTxDuplicate(txs []*commonPb.Transaction) (duplicate bool, duplicateTxs []string)
IsTxDuplicate to check if there is duplicated transactions in one block
func IsTxRWSetValid ¶
func IsTxRWSetValid(block *commonpb.Block, tx *commonpb.Transaction, rwSet *commonpb.TxRWSet, result *commonpb.Result, rwsetHash []byte) error
IsTxRWSetValid, to check if transaction read write set is valid
func IsTxRequestValid ¶
func IsTxRequestValid(tx *commonpb.Transaction, txInPool *commonpb.Transaction) error
IsTxRequestValid, to check if transaction request payload is valid
func NewBlockCommitter ¶
func NewBlockCommitter(config BlockCommitterConfig, log protocol.Logger) (protocol.BlockCommitter, error)
func NotifyChainConf ¶
NotifyChainConf Notify each module of callback before version v2.3.0
func RecoverBlock ¶
func RetryAndRemoveTxs ¶
func RetryAndRemoveTxs( txPool protocol.TxPool, txsRetry []*commonPb.Transaction, txsRem []*commonPb.Transaction, log protocol.Logger)
RetryAndRemoveTxs filter charging gas tx out before call tx pool
func SerializeTxBatchInfo ¶
func SerializeTxBatchInfo(batchIds []string, txs []*commonPb.Transaction, fetchBatches [][]*commonPb.Transaction, logger protocol.Logger) ([]byte, error)
func TxVerifyResultsMerge ¶
func TxVerifyResultsMerge(resultTasks map[int]VerifyBlockBatch, verifyBatchs map[int][]*commonpb.Transaction) ([][]byte, []*commonpb.Transaction, error)
func ValidateTx ¶
func ValidateTx(txsRet map[string]*commonpb.Transaction, tx *commonpb.Transaction, stat *VerifyStat, newAddTxs []*commonpb.Transaction, block *commonpb.Block, consensusType consensuspb.ConsensusType, filter protocol.TxFilter, chainId string, ac protocol.AccessControlProvider, proposalCache protocol.ProposalCache, mode protocol.VerifyMode, verifyMode uint8, options ...string) error
func ValidateTxRules ¶
func ValidateTxRules(filter protocol.TxFilter, txs []*commonpb.Transaction) ( removeTxs []*commonpb.Transaction, remainTxs []*commonpb.Transaction)
ValidateTxRules validate Transactions and return remain Transactions and Transactions that need to be removed
func VerifyHeight ¶
func VerifyHeight(height uint64, ledgerCache protocol.LedgerCache) error
func VerifyTxResult ¶
func VerifyTxResult(tx *commonpb.Transaction, result *commonpb.Result) error
VerifyTxResult, to check if transaction result is valid, compare result simulate in this node with executed in other node
Types ¶
type BlockBuilder ¶
type BlockBuilder struct {
// contains filtered or unexported fields
}
func NewBlockBuilder ¶
func NewBlockBuilder(conf *BlockBuilderConf) *BlockBuilder
func (*BlockBuilder) GenerateNewBlock ¶
func (bb *BlockBuilder) GenerateNewBlock( proposingHeight uint64, preHash []byte, txBatch []*commonPb.Transaction, batchIds []string, fetchBatches [][]*commonPb.Transaction) ( *commonPb.Block, []int64, error)
type BlockBuilderConf ¶
type BlockBuilderConf struct { ChainId string // chain id, to identity this chain TxPool protocol.TxPool // tx pool provides tx batch TxScheduler protocol.TxScheduler // scheduler orders tx batch into DAG form and returns a block SnapshotManager protocol.SnapshotManager // snapshot manager Identity protocol.SigningParticipant // identity manager LedgerCache protocol.LedgerCache // ledger cache ProposalCache protocol.ProposalCache ChainConf protocol.ChainConf // chain config Log protocol.Logger StoreHelper conf.StoreHelper }
type BlockCommitterConfig ¶
type BlockCommitterConfig struct { ChainId string BlockchainStore protocol.BlockchainStore SnapshotManager protocol.SnapshotManager TxPool protocol.TxPool LedgerCache protocol.LedgerCache ProposedCache protocol.ProposalCache ChainConf protocol.ChainConf MsgBus msgbus.MessageBus Subscriber *subscriber.EventSubscriber Verifier protocol.BlockVerifier StoreHelper conf.StoreHelper TxFilter protocol.TxFilter }
type BlockCommitterImpl ¶
type BlockCommitterImpl struct {
// contains filtered or unexported fields
}
BlockCommitterImpl implements BlockCommitter interface. To commit a block after it is confirmed by consensus module.
type CommitBlock ¶
type CommitBlock struct {
// contains filtered or unexported fields
}
func (*CommitBlock) CommitBlock ¶
func (cb *CommitBlock) CommitBlock( block *commonpb.Block, rwSetMap map[string]*commonpb.TxRWSet, conEventMap map[string][]*commonpb.ContractEvent) ( dbLasts, snapshotLasts, confLasts, otherLasts, pubEventLasts, filterLasts int64, blockInfo *commonpb.BlockInfo, err error)
CommitBlock the action that all consensus types do when a block is committed
func (*CommitBlock) NotifyMessage ¶
func (cb *CommitBlock) NotifyMessage(block *commonpb.Block, events []*commonpb.ContractEvent) (err error)
NotifyMessage Notify other subscription modules of chain configuration and certificate management events
type KVStoreHelper ¶
type KVStoreHelper struct {
// contains filtered or unexported fields
}
func NewKVStoreHelper ¶
func NewKVStoreHelper(chainId string) *KVStoreHelper
func (*KVStoreHelper) BeginDbTransaction ¶
func (kv *KVStoreHelper) BeginDbTransaction(blockchainStore protocol.BlockchainStore, txKey string)
KVDB do nothing
func (*KVStoreHelper) GetPoolCapacity ¶
func (kv *KVStoreHelper) GetPoolCapacity() int
func (*KVStoreHelper) RollBack ¶
func (kv *KVStoreHelper) RollBack(block *commonpb.Block, blockchainStore protocol.BlockchainStore) error
KVDB do nothing
type ReentrantLocks ¶
reentrantLocks, avoid the same block hash
func (*ReentrantLocks) Lock ¶
func (l *ReentrantLocks) Lock(key string) bool
func (*ReentrantLocks) Unlock ¶
func (l *ReentrantLocks) Unlock(key string) bool
type RwSetVerifyFailTx ¶
type SQLStoreHelper ¶
type SQLStoreHelper struct {
// contains filtered or unexported fields
}
func NewSQLStoreHelper ¶
func NewSQLStoreHelper(chainId string) *SQLStoreHelper
func (*SQLStoreHelper) BeginDbTransaction ¶
func (sql *SQLStoreHelper) BeginDbTransaction(blockchainStore protocol.BlockchainStore, txKey string)
func (*SQLStoreHelper) GetPoolCapacity ¶
func (sql *SQLStoreHelper) GetPoolCapacity() int
func (*SQLStoreHelper) RollBack ¶
func (sql *SQLStoreHelper) RollBack(block *commonpb.Block, blockchainStore protocol.BlockchainStore) error
type VerifierBlock ¶
type VerifierBlock struct {
// contains filtered or unexported fields
}
func NewVerifierBlock ¶
func NewVerifierBlock(conf *VerifierBlockConf) *VerifierBlock
func (*VerifierBlock) FetchLastBlock ¶
func (*VerifierBlock) SetTxScheduler ¶
func (v *VerifierBlock) SetTxScheduler(txScheduler protocol.TxScheduler)
SetTxScheduler sets the txScheduler of VerifierBlock only used for test
func (*VerifierBlock) ValidateBlock ¶
func (vb *VerifierBlock) ValidateBlock( block, lastBlock *commonPb.Block, hashType string, timeLasts map[string]int64, mode protocol.VerifyMode) ( map[string]*commonPb.TxRWSet, map[string][]*commonPb.ContractEvent, map[string]int64, *RwSetVerifyFailTx, error)
validateBlock, validate block and transactions
func (*VerifierBlock) ValidateBlockWithRWSets ¶
func (vb *VerifierBlock) ValidateBlockWithRWSets( block, lastBlock *commonPb.Block, hashType string, timeLasts map[string]int64, txRWSetMap map[string]*commonPb.TxRWSet, mode protocol.VerifyMode) ( map[string][]*commonPb.ContractEvent, map[string]int64, *RwSetVerifyFailTx, error)
validateBlock, validate block and transactions
type VerifierBlockConf ¶
type VerifierBlockConf struct { ChainConf protocol.ChainConf Log protocol.Logger LedgerCache protocol.LedgerCache Ac protocol.AccessControlProvider SnapshotManager protocol.SnapshotManager VmMgr protocol.VmManager TxPool protocol.TxPool BlockchainStore protocol.BlockchainStore ProposalCache protocol.ProposalCache // proposal cache StoreHelper conf.StoreHelper TxScheduler protocol.TxScheduler TxFilter protocol.TxFilter }
type VerifierTx ¶
type VerifierTx struct {
// contains filtered or unexported fields
}
func NewVerifierTx ¶
func NewVerifierTx(conf *VerifierTxConfig) *VerifierTx
type VerifierTxConfig ¶
type VerifierTxConfig struct { Block *commonpb.Block TxRWSetMap map[string]*commonpb.TxRWSet TxResultMap map[string]*commonpb.Result Log protocol.Logger TxFilter protocol.TxFilter TxPool protocol.TxPool Ac protocol.AccessControlProvider ChainConf protocol.ChainConf ProposalCache protocol.ProposalCache }
type VerifyBlockBatch ¶
type VerifyBlockBatch struct {
// contains filtered or unexported fields
}
func NewVerifyBlockBatch ¶
func NewVerifyBlockBatch(txs, newAddTxs []*commonpb.Transaction, txHash [][]byte) VerifyBlockBatch