Documentation ¶
Index ¶
- Constants
- Variables
- func DisableLog()
- func ErrToRejectErr(err error) (msg.RejectCode, string)
- func GenesisToProgramHash(genesisHash *common.Uint256) (*common.Uint168, error)
- func NewConflictSlot(t KeyType, conflictTypes ...KeyTypeFuncPair) *conflictSlot
- 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 Conflict
- type ErrorCode
- type FeeHelper
- type FuncName
- type GetKeyFunc
- type KeyType
- type KeyTypeFuncPair
- type RuleError
- type TxPool
- func (m *TxPool) AddConflictSlot(conflict *Conflict)
- func (p *TxPool) AppendToTxPool(tx *types.Transaction) error
- func (m *TxPool) AppendTx(tx *types.Transaction) error
- func (p *TxPool) CleanSubmittedTransactions(block *types.Block) error
- func (m *TxPool) ContainsKey(key interface{}, slotName string) bool
- func (m *TxPool) Empty() bool
- func (p *TxPool) GetTransaction(hash common.Uint256) *types.Transaction
- func (m *TxPool) GetTx(key interface{}, slotName string) *types.Transaction
- func (p *TxPool) GetTxsInPool() map[common.Uint256]*types.Transaction
- func (p *TxPool) HaveTransaction(txId common.Uint256) bool
- func (mp *TxPool) IsDuplicateMainChainTx(mainchainTxHash common.Uint256) bool
- func (p *TxPool) MaybeAcceptTransaction(txn *types.Transaction) error
- func (m *TxPool) RemoveKey(key interface{}, slotName string) error
- func (p *TxPool) RemoveTransaction(txn *types.Transaction)
- func (m *TxPool) VerifyTx(tx *types.Transaction) error
- type TxValidateAction
- type Validator
- func (v *Validator) CheckTransactionContext(txn *types.Transaction, height uint32, mainChainHeight uint32) error
- func (v *Validator) CheckTransactionSanity(txn *types.Transaction, height uint32, mainChainHeight uint32) error
- func (v *Validator) GetFeeHelper() *FeeHelper
- func (v *Validator) GetParams() *config.Params
- func (v *Validator) RegisterContextFunc(name FuncName, ...)
- func (v *Validator) RegisterSanityFunc(name FuncName, ...)
- func (v *Validator) TxProgramHashes(tx *types.Transaction) ([]common.Uint168, error)
Constants ¶
const ( SlotRechargeToSidechainTxHash = "RechargeToSidechainTxHash" SlotTxInputsReferKeys = "TxInputsReferKeys" )
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 NewConflictSlot ¶ added in v0.1.7
func NewConflictSlot(t KeyType, conflictTypes ...KeyTypeFuncPair) *conflictSlot
func RunPrograms ¶
func SortPrograms ¶
Types ¶
type Config ¶
type Config struct { ChainParams *config.Params Chain *blockchain.BlockChain 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 GetKeyFunc ¶ added in v0.1.7
type GetKeyFunc func(*blockchain.BlockChain, *types.Transaction) (interface{}, error)
GetKeyFunc defines the general function about get key from a tx.
type KeyType ¶ added in v0.1.7
type KeyType byte
KeyType defines the conflictSlot supported key types.
const ( // Str KeyType will treat key as type of string. Str KeyType = iota // Hash KeyType will treat key as type of Uint256. Hash // ProgramHash KeyType will treat key as type of Uint168. ProgramHash // Hash KeyType will treat key as type of string array. StrArray // Hash KeyType will treat key as type of Uint256 array. HashArray // ProgramHash KeyType will treat key as type of Uint168 array. ProgramHashArray )
type KeyTypeFuncPair ¶ added in v0.1.7
type KeyTypeFuncPair struct { Type types.TxType Func GetKeyFunc }
KeyTypeFuncPair defines a pair about tx type and related GetKeyFunc.
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) AddConflictSlot ¶ added in v0.1.7
func (m *TxPool) AddConflictSlot(conflict *Conflict)
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) AppendTx ¶ added in v0.1.7
func (m *TxPool) AppendTx(tx *types.Transaction) error
func (*TxPool) CleanSubmittedTransactions ¶
clean the trasaction Pool with committed block.
func (*TxPool) ContainsKey ¶ added in v0.1.7
func (*TxPool) GetTransaction ¶
func (p *TxPool) GetTransaction(hash common.Uint256) *types.Transaction
get the transaction by hash
func (*TxPool) GetTx ¶ added in v0.1.7
func (m *TxPool) GetTx(key interface{}, slotName string) *types.Transaction
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 ¶ added in v0.1.7
func (*TxPool) MaybeAcceptTransaction ¶
func (p *TxPool) MaybeAcceptTransaction(txn *types.Transaction) error
func (*TxPool) RemoveTransaction ¶
func (p *TxPool) RemoveTransaction(txn *types.Transaction)
func (*TxPool) VerifyTx ¶ added in v0.1.7
func (m *TxPool) VerifyTx(tx *types.Transaction) error
type TxValidateAction ¶
type Validator ¶
type Validator struct { Chain *blockchain.BlockChain // contains filtered or unexported fields }
func NewValidator ¶
func (*Validator) CheckTransactionContext ¶
func (v *Validator) CheckTransactionContext(txn *types.Transaction, height uint32, mainChainHeight uint32) error
CheckTransactionContext verifys a transaction with history transaction in ledger
func (*Validator) CheckTransactionSanity ¶
func (v *Validator) CheckTransactionSanity(txn *types.Transaction, height uint32, mainChainHeight uint32) error
CheckTransactionSanity verifys received single transaction