Documentation ¶
Index ¶
- Constants
- func IsOrphanError(err error) bool
- func NewValidateError(code ValidationCode) error
- func ValidateUnitBasic(unit *modules.Unit) error
- type BuildTempContractDagFunc
- type ContractTxCheckFunc
- type IDagQuery
- type IPropQuery
- type IStateQuery
- type IUtxoQuery
- type Validate
- func (validate *Validate) CheckTxIsExist(tx *modules.Transaction) bool
- func (validate *Validate) SetContractTxCheckFun(checkFun ContractTxCheckFunc)
- func (validate *Validate) SetUtxoQuery(query IUtxoQuery)
- func (validate *Validate) ValidateHeader(h *modules.Header) ValidationCode
- func (validate *Validate) ValidateTx(tx *modules.Transaction, isFullTx bool) ([]*modules.Addition, ValidationCode, error)
- func (validate *Validate) ValidateTxFeeEnough(tx *modules.Transaction, extSize float64, extTime float64) ValidationCode
- func (validate *Validate) ValidateUnitExceptGroupSig(unit *modules.Unit) ValidationCode
- func (validate *Validate) ValidateUnitGroupSign(h *modules.Header) error
- type ValidationCode
- type Validator
- type ValidatorAllPass
- func (v *ValidatorAllPass) CheckTxIsExist(tx *modules.Transaction) bool
- func (v *ValidatorAllPass) SetContractTxCheckFun(checkFun ContractTxCheckFunc)
- func (v *ValidatorAllPass) SetUtxoQuery(query IUtxoQuery)
- func (v *ValidatorAllPass) ValidateHeader(h *modules.Header) ValidationCode
- func (v *ValidatorAllPass) ValidateTx(tx *modules.Transaction, isFullTx bool) ([]*modules.Addition, ValidationCode, error)
- func (v *ValidatorAllPass) ValidateTxFeeEnough(tx *modules.Transaction, extSize float64, extTime float64) ValidationCode
- func (v *ValidatorAllPass) ValidateUnitExceptGroupSig(unit *modules.Unit) ValidationCode
- func (v *ValidatorAllPass) ValidateUnitGroupSign(h *modules.Header) error
- type ValidatorBuilderFunc
- type ValidatorCache
- func (s *ValidatorCache) AddHeaderValidateResult(unitHash common.Hash, code ValidationCode)
- func (s *ValidatorCache) AddTxValidateResult(txId common.Hash, validateResult []*modules.Addition)
- func (s *ValidatorCache) AddUnitValidateResult(unitHash common.Hash, code ValidationCode)
- func (s *ValidatorCache) HasHeaderValidateResult(unitHash common.Hash) (bool, ValidationCode)
- func (s *ValidatorCache) HasTxValidateResult(txId common.Hash) (bool, []*modules.Addition)
- func (s *ValidatorCache) HasUnitValidateResult(unitHash common.Hash) (bool, ValidationCode)
Constants ¶
View Source
const ENABLE_CONTRACT_DEVELOPER_CHECK_TIME = 1577808000 //2020-1-1
View Source
const ENABLE_CONTRACT_RWSET_CHECK_TIME = 2588262400 //2020-5-1
View Source
const ENABLE_CONTRACT_SIGN_CHECK_TIME = 1588348800 //2019-12-1
View Source
const ENABLE_TX_FEE_CHECK_TIME = 1570870800 //2019-10-12 17:00:00
View Source
const ENABLE_TX_FULL_CHECK_TIME = 1588348800
Variables ¶
This section is empty.
Functions ¶
func IsOrphanError ¶
func NewValidateError ¶
func NewValidateError(code ValidationCode) error
func ValidateUnitBasic ¶ added in v1.0.1
不基于数据库,进行Unit最基本的验证
Types ¶
type BuildTempContractDagFunc ¶ added in v1.0.6
type BuildTempContractDagFunc func(dag dboperation.IContractDag) dboperation.IContractDag
type ContractTxCheckFunc ¶ added in v1.0.5
type ContractTxCheckFunc func(tx *modules.Transaction, rwM rwset.TxManager, dag dboperation.IContractDag) bool
type IPropQuery ¶
type IPropQuery interface { GetSlotAtTime(when time.Time) uint32 GetScheduledMediator(slotNum uint32) common.Address GetNewestUnitTimestamp(token modules.AssetId) (int64, error) GetNewestUnit(token modules.AssetId) (common.Hash, *modules.ChainIndex, error) GetChainParameters() *core.ChainParameters }
type IStateQuery ¶
type IStateQuery interface { GetContractTpl(tplId []byte) (*modules.ContractTemplate, error) GetContractJury(contractId []byte) (*modules.ElectionNode, error) GetContractState(id []byte, field string) ([]byte, *modules.StateVersion, error) GetContractStatesByPrefix(id []byte, prefix string) (map[string]*modules.ContractStateValue, error) GetMediators() map[common.Address]bool GetMediator(add common.Address) *core.Mediator GetBlacklistAddress() ([]common.Address, *modules.StateVersion, error) GetJurorByAddrHash(addrHash common.Hash) (*modules.JurorDeposit, error) GetJurorReward(jurorAdd common.Address) common.Address IsContractDeveloper(addr common.Address) bool }
type IUtxoQuery ¶
type Validate ¶
type Validate struct {
// contains filtered or unexported fields
}
func (*Validate) CheckTxIsExist ¶
func (validate *Validate) CheckTxIsExist(tx *modules.Transaction) bool
func (*Validate) SetContractTxCheckFun ¶ added in v1.0.5
func (validate *Validate) SetContractTxCheckFun(checkFun ContractTxCheckFunc)
func (validate *Validate) ContractTxCheck(rwM rwset.TxManager, tx *modules.Transaction) bool { if validate.contractCheckFun != nil { return validate.contractCheckFun(rwM,dag, tx) } return true }
func (*Validate) SetUtxoQuery ¶ added in v1.0.7
func (validate *Validate) SetUtxoQuery(query IUtxoQuery)
func (v *Validate) SetBuildTempContractDagFunc(buildFunc BuildTempContractDagFunc) { v.buildTempDagFunc = buildFunc log.Debug("SetBuildTempContractDagFunc ok") }
func (*Validate) ValidateHeader ¶
func (validate *Validate) ValidateHeader(h *modules.Header) ValidationCode
func (*Validate) ValidateTx ¶
func (validate *Validate) ValidateTx(tx *modules.Transaction, isFullTx bool) ([]*modules.Addition, ValidationCode, error)
* 检查unit中所有交易的合法性,返回所有交易的交易费总和 check all transactions in one unit return all transactions' fee
func (validate *Validate) ValidateTransactions(txs modules.Transactions) error { code := validate.validateTransactions(txs) return NewValidateError(code) }
验证一个Tx是否满足被接受的条件,并返回该Tx的手续费分配情况,验证结果,如果验证结果不是Valid,则err有值
func (*Validate) ValidateTxFeeEnough ¶ added in v1.0.4
func (validate *Validate) ValidateTxFeeEnough(tx *modules.Transaction, extSize float64, extTime float64) ValidationCode
extSize :byte, extTime :s
func (*Validate) ValidateUnitExceptGroupSig ¶
func (validate *Validate) ValidateUnitExceptGroupSig(unit *modules.Unit) ValidationCode
* 验证Unit Validate unit(除群签名以外), 新生产的unit暂时还没有群签名
func (validate *Validate) ValidateUnit(unit *modules.Unit, isGenesis bool) byte {
type ValidationCode ¶
type ValidationCode byte
const ( TxValidationCode_VALID ValidationCode = 0 TxValidationCode_INVALID_CONTRACT_TEMPLATE ValidationCode = 1 TxValidationCode_INVALID_FEE ValidationCode = 2 TxValidationCode_BAD_COMMON_HEADER ValidationCode = 3 TxValidationCode_BAD_CREATOR_SIGNATURE ValidationCode = 4 TxValidationCode_INVALID_ENDORSER_TRANSACTION ValidationCode = 5 TxValidationCode_INVALID_CONFIG_TRANSACTION ValidationCode = 6 TxValidationCode_UNSUPPORTED_TX_PAYLOAD ValidationCode = 7 TxValidationCode_BAD_PROPOSAL_TXID ValidationCode = 8 TxValidationCode_DUPLICATE_TXID ValidationCode = 9 TxValidationCode_ENDORSEMENT_POLICY_FAILURE ValidationCode = 10 TxValidationCode_MVCC_READ_CONFLICT ValidationCode = 11 TxValidationCode_PHANTOM_READ_CONFLICT ValidationCode = 12 TxValidationCode_UNKNOWN_TX_TYPE ValidationCode = 13 TxValidationCode_STATE_DATA_NOT_FOUND ValidationCode = 14 TxValidationCode_MARSHAL_TX_ERROR ValidationCode = 15 TxValidationCode_NIL_TXACTION ValidationCode = 16 TxValidationCode_EXPIRED_CHAINCODE ValidationCode = 17 TxValidationCode_CHAINCODE_VERSION_CONFLICT ValidationCode = 18 TxValidationCode_BAD_HEADER_EXTENSION ValidationCode = 19 TxValidationCode_BAD_CHANNEL_HEADER ValidationCode = 20 TxValidationCode_BAD_RESPONSE_PAYLOAD ValidationCode = 21 TxValidationCode_BAD_RWSET ValidationCode = 22 TxValidationCode_INVALID_SIGNATURE ValidationCode = 23 TxValidationCode_INVALID_CONTRACT_SIGN ValidationCode = 24 TxValidationCode_INVALID_MSG ValidationCode = 25 TxValidationCode_INVALID_PAYMMENTLOAD ValidationCode = 26 TxValidationCode_INVALID_PAYMMENT_INPUT ValidationCode = 27 TxValidationCode_INVALID_PAYMMENT_INPUT_COUNT ValidationCode = 28 TxValidationCode_INVALID_COINBASE ValidationCode = 29 TxValidationCode_ADDRESS_IN_BLACKLIST ValidationCode = 30 TxValidationCode_INVALID_AMOUNT ValidationCode = 31 TxValidationCode_INVALID_ASSET ValidationCode = 32 TxValidationCode_INVALID_CONTRACT ValidationCode = 33 TxValidationCode_INVALID_DATAPAYLOAD ValidationCode = 34 TxValidationCode_INVALID_DOUBLE_SPEND ValidationCode = 35 TxValidationCode_INVALID_TOKEN_STATUS ValidationCode = 36 TxValidationCode_NOT_COMPARE_SIZE ValidationCode = 37 TxValidationCode_NOT_TPL_DEVELOPER ValidationCode = 38 TxValidationCode_ORPHAN ValidationCode = 255 TxValidationCode_INVALID_OTHER_REASON ValidationCode = 251 TxValidationCode_NOT_VALIDATED ValidationCode = 250 UNIT_STATE_AUTHOR_SIGNATURE_PASSED ValidationCode = 101 UNIT_STATE_INVALID_MEDIATOR_SCHEDULE ValidationCode = 102 UNIT_STATE_INVALID_AUTHOR_SIGNATURE ValidationCode = 103 UNIT_STATE_INVALID_GROUP_SIGNATURE ValidationCode = 104 UNIT_STATE_HAS_INVALID_TRANSACTIONS ValidationCode = 105 UNIT_STATE_INVALID_AUTHOR ValidationCode = 106 UNIT_STATE_INVALID_EXTRA_DATA ValidationCode = 107 UNIT_STATE_INVALID_HEADER ValidationCode = 108 UNIT_STATE_INVALID_HEADER_NUMBER ValidationCode = 109 UNIT_STATE_INVALID_HEADER_TXROOT ValidationCode = 110 UNIT_STATE_INVALID_HEADER_TIME ValidationCode = 111 UNIT_STATE_ORPHAN ValidationCode = 254 )
type Validator ¶
type Validator interface { //验证一个交易是否是合法交易 //isCoinbase //isFullTx这个交易是完整的可打包的交易,还是陪审团没处理或者正在处理中的交易 ValidateTx(tx *modules.Transaction, isFullTx bool) ([]*modules.Addition, ValidationCode, error) //验证一个Unit中的所有交易是否是合法交易 //ValidateTransactions(txs modules.Transactions) error //除了群签名外,验证Unit是否是合法Unit,包括其中的所有交易都会逐一验证 ValidateUnitExceptGroupSig(unit *modules.Unit) ValidationCode //ValidateUnitExceptPayment(unit *modules.Unit) error //验证一个Header是否合法(Mediator签名有效),主要用于轻节点 ValidateHeader(h *modules.Header) ValidationCode ValidateUnitGroupSign(h *modules.Header) error ValidateTxFeeEnough(tx *modules.Transaction, extSize float64, extTime float64) ValidationCode CheckTxIsExist(tx *modules.Transaction) bool SetContractTxCheckFun(checkFun ContractTxCheckFunc) SetUtxoQuery(query IUtxoQuery) }
func NewValidate ¶
func NewValidate(dagdb IDagQuery, utxoRep IUtxoQuery, statedb IStateQuery, propquery IPropQuery, contractDag dboperation.IContractDag, cache palletcache.ICache, light bool, enableGasFee bool) Validator
func NewValidatorAllPass ¶ added in v1.0.6
func NewValidatorAllPass(dagdb IDagQuery, utxoRep IUtxoQuery, statedb IStateQuery, propquery IPropQuery, contractDag dboperation.IContractDag, cache palletcache.ICache, light, enableGasFee bool) Validator
type ValidatorAllPass ¶ added in v1.0.3
type ValidatorAllPass struct { }
ValidatorAllPass used for UT
func (*ValidatorAllPass) CheckTxIsExist ¶ added in v1.0.3
func (v *ValidatorAllPass) CheckTxIsExist(tx *modules.Transaction) bool
func (*ValidatorAllPass) SetContractTxCheckFun ¶ added in v1.0.6
func (v *ValidatorAllPass) SetContractTxCheckFun(checkFun ContractTxCheckFunc)
func (*ValidatorAllPass) SetUtxoQuery ¶ added in v1.0.7
func (v *ValidatorAllPass) SetUtxoQuery(query IUtxoQuery)
func (*ValidatorAllPass) ValidateHeader ¶ added in v1.0.3
func (v *ValidatorAllPass) ValidateHeader(h *modules.Header) ValidationCode
ValidateUnitExceptPayment(unit *modules.Unit) error 验证一个Header是否合法(Mediator签名有效)
func (*ValidatorAllPass) ValidateTx ¶ added in v1.0.3
func (v *ValidatorAllPass) ValidateTx(tx *modules.Transaction, isFullTx bool) ([]*modules.Addition, ValidationCode, error)
func (*ValidatorAllPass) ValidateTxFeeEnough ¶ added in v1.0.6
func (v *ValidatorAllPass) ValidateTxFeeEnough(tx *modules.Transaction, extSize float64, extTime float64) ValidationCode
func (*ValidatorAllPass) ValidateUnitExceptGroupSig ¶ added in v1.0.3
func (v *ValidatorAllPass) ValidateUnitExceptGroupSig(unit *modules.Unit) ValidationCode
验证一个Unit中的所有交易是否是合法交易 ValidateTransactions(txs modules.Transactions) error 除了群签名外,验证Unit是否是合法Unit,包括其中的所有交易都会逐一验证
func (*ValidatorAllPass) ValidateUnitGroupSign ¶ added in v1.0.3
func (v *ValidatorAllPass) ValidateUnitGroupSign(h *modules.Header) error
type ValidatorBuilderFunc ¶ added in v1.0.6
type ValidatorBuilderFunc func(dagdb IDagQuery, utxoRep IUtxoQuery, statedb IStateQuery, propquery IPropQuery, contractDag dboperation.IContractDag, cache palletcache.ICache, light bool, enableGasFee bool) Validator
type ValidatorCache ¶ added in v1.0.1
type ValidatorCache struct {
// contains filtered or unexported fields
}
如果已经验证通过的对象,那么不需要重复做全部验证
func NewValidatorCache ¶ added in v1.0.1
func NewValidatorCache(cache palletcache.ICache) *ValidatorCache
func (*ValidatorCache) AddHeaderValidateResult ¶ added in v1.0.1
func (s *ValidatorCache) AddHeaderValidateResult(unitHash common.Hash, code ValidationCode)
func (*ValidatorCache) AddTxValidateResult ¶ added in v1.0.1
func (s *ValidatorCache) AddTxValidateResult(txId common.Hash, validateResult []*modules.Addition)
func (*ValidatorCache) AddUnitValidateResult ¶ added in v1.0.1
func (s *ValidatorCache) AddUnitValidateResult(unitHash common.Hash, code ValidationCode)
func (*ValidatorCache) HasHeaderValidateResult ¶ added in v1.0.1
func (s *ValidatorCache) HasHeaderValidateResult(unitHash common.Hash) (bool, ValidationCode)
func (*ValidatorCache) HasTxValidateResult ¶ added in v1.0.1
func (*ValidatorCache) HasUnitValidateResult ¶ added in v1.0.1
func (s *ValidatorCache) HasUnitValidateResult(unitHash common.Hash) (bool, ValidationCode)
Click to show internal directories.
Click to hide internal directories.