Documentation ¶
Index ¶
- Variables
- func DisableLog()
- func ErrToRejectErr(err error) (msg.RejectCode, string)
- func GenesisToProgramHash(genesisHash *common.Uint256) (*common.Uint168, error)
- func RunPrograms(tx *types.Transaction, hashes []common.Uint168, programs []*types.Program) error
- func SortPrograms(programs []*types.Program) (err error)
- func UseLogger(logger elalog.Logger)
- type Config
- type ErrorCode
- type FeeHelper
- type FuncName
- type RuleError
- type TxPool
- func (p *TxPool) AppendToTxPool(tx *types.Transaction) error
- func (p *TxPool) CleanSubmittedTransactions(block *types.Block) error
- func (p *TxPool) GetTransaction(hash common.Uint256) *types.Transaction
- func (p *TxPool) GetTxsInPool() map[common.Uint256]*types.Transaction
- func (p *TxPool) HaveTransaction(txId common.Uint256) bool
- func (p *TxPool) IsDuplicateMainchainTx(mainchainTxHash common.Uint256) bool
- func (p *TxPool) MaybeAcceptTransaction(txn *types.Transaction) error
- func (p *TxPool) RemoveTransaction(txn *types.Transaction)
- type TxValidateAction
- type Validator
- func (v *Validator) CheckTransactionContext(txn *types.Transaction) error
- func (v *Validator) CheckTransactionSanity(txn *types.Transaction) error
- func (v *Validator) RegisterContextFunc(name FuncName, function func(txn *types.Transaction) error)
- func (v *Validator) RegisterSanityFunc(name FuncName, function func(txn *types.Transaction) error)
- func (v *Validator) TxProgramHashes(tx *types.Transaction) ([]common.Uint168, error)
Constants ¶
This section is empty.
Variables ¶
var ErrBreak = fmt.Errorf("break out from here")
var (
FuncNames = funcNames{
CheckTransactionSize: "checktransactionsize",
CheckTransactionInput: "checktransactioninput",
CheckTransactionOutput: "checktransactionoutput",
CheckAssetPrecision: "checkassetprecision",
CheckAttributeProgram: "checkattributeprogram",
CheckTransactionPayload: "checktransactionpayload",
CheckTransactionDuplicate: "checktransactionduplicate",
CheckTransactionCoinBase: "checktransactioncoinbase",
CheckTransactionDoubleSpend: "checktransactiondoublespend",
CheckTransactionSignature: "checktransactionsignature",
CheckRechargeToSideChainTransaction: "checkrechargetosidechaintransaction",
CheckTransferCrossChainAssetTransaction: "checktransfercrosschainassettransaction",
CheckTransactionUTXOLock: "checktransactionutxolock",
CheckTransactionBalance: "checktransactionbalance",
CheckReferencedOutput: "checkreferencedoutput",
}
)
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
func ErrToRejectErr ¶ added in v0.1.3
func ErrToRejectErr(err error) (msg.RejectCode, string)
ErrToRejectErr examines the underlying type of the error and returns a reject code and string appropriate to be sent in a wire.MsgReject message.
func GenesisToProgramHash ¶
func RunPrograms ¶
func SortPrograms ¶
Types ¶
type Config ¶
type Config struct { ChainParams *config.Params ChainStore *blockchain.ChainStore SpvService *spv.Service Validator *Validator FeeHelper *FeeHelper }
type ErrorCode ¶
type ErrorCode int
const ( ErrInvalidInput ErrorCode = 45003 ErrInvalidOutput ErrorCode = 45004 ErrAssetPrecision ErrorCode = 45005 ErrTransactionBalance ErrorCode = 45006 ErrAttributeProgram ErrorCode = 45007 ErrTransactionSignature ErrorCode = 45008 ErrTransactionPayload ErrorCode = 45009 ErrDoubleSpend ErrorCode = 45010 ErrTxHashDuplicate ErrorCode = 45011 ErrMainchainTxDuplicate ErrorCode = 45013 ErrTransactionSize ErrorCode = 45015 ErrUnknownReferedTx ErrorCode = 45016 ErrInvalidReferedTx ErrorCode = 45017 ErrIneffectiveCoinbase ErrorCode = 45018 ErrUTXOLocked ErrorCode = 45019 ErrRechargeToSideChain ErrorCode = 45020 ErrCrossChain ErrorCode = 45021 )
type FeeHelper ¶
type FeeHelper struct {
// contains filtered or unexported fields
}
func NewFeeHelper ¶
func (*FeeHelper) GetTxFeeMap ¶
type RuleError ¶
type RuleError struct { ErrorCode ErrorCode // Describes the kind of error Description string // Human readable description of the issue }
RuleError identifies a rule violation. It is used to indicate that processing of a block or transaction failed due to one of the many validation rules. The caller can use type assertions to determine if a failure was specifically due to a rule violation and access the ErrorCode field to ascertain the specific reason for the rule violation.
type TxPool ¶
func (*TxPool) AppendToTxPool ¶
func (p *TxPool) AppendToTxPool(tx *types.Transaction) error
append transaction to txnpool when check ok. 1.check 2.check with ledger(db) 3.check with pool
func (*TxPool) CleanSubmittedTransactions ¶
clean the trasaction Pool with committed block.
func (*TxPool) GetTransaction ¶
func (p *TxPool) GetTransaction(hash common.Uint256) *types.Transaction
get the transaction by hash
func (*TxPool) GetTxsInPool ¶
func (p *TxPool) GetTxsInPool() map[common.Uint256]*types.Transaction
GetTxsInPool returns a copy of the transactions in transaction pool, It is safe to modify the returned map.
func (*TxPool) HaveTransaction ¶
HaveTransaction returns if a transaction is in transaction pool by the given transaction id. If no transaction match the transaction id, return false
func (*TxPool) IsDuplicateMainchainTx ¶
func (*TxPool) MaybeAcceptTransaction ¶
func (p *TxPool) MaybeAcceptTransaction(txn *types.Transaction) error
func (*TxPool) RemoveTransaction ¶
func (p *TxPool) RemoveTransaction(txn *types.Transaction)
type TxValidateAction ¶
type TxValidateAction struct { Name FuncName Handler func(txn *types.Transaction) error }
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
func NewValidator ¶
func (*Validator) CheckTransactionContext ¶
func (v *Validator) CheckTransactionContext(txn *types.Transaction) error
CheckTransactionContext verifys a transaction with history transaction in ledger
func (*Validator) CheckTransactionSanity ¶
func (v *Validator) CheckTransactionSanity(txn *types.Transaction) error
CheckTransactionSanity verifys received single transaction
func (*Validator) RegisterContextFunc ¶
func (v *Validator) RegisterContextFunc(name FuncName, function func(txn *types.Transaction) error)
func (*Validator) RegisterSanityFunc ¶
func (v *Validator) RegisterSanityFunc(name FuncName, function func(txn *types.Transaction) error)