Documentation ¶
Index ¶
- Constants
- func BlockDataToBytes(blk BlockData) ([]byte, error)
- func GetSourceNetworkUID(c interface{ ... }) []byte
- func SourceNetworkUID(nid int) []byte
- type APIInfo
- type Address
- type BTPBlockHeader
- type BTPDigest
- type BTPMessage
- type BTPMessageList
- type BTPNetwork
- type BTPNetworkType
- type BTPProof
- type BTPProofContext
- type BTPProofContextMap
- type BTPProofContextMapUpdateSource
- type BTPProofPart
- type BTPSection
- type BaseWallet
- type BitSetFilter
- type Block
- type BlockCandidate
- type BlockData
- type BlockDataFactory
- type BlockInfo
- type BlockManager
- type BroadcastType
- type BytesHasher
- type BytesList
- type BytesSlice
- type Canceler
- type Chain
- type CommitVoteSet
- type CommitVoteSetDecoder
- type Consensus
- type ConsensusInfo
- type ConsensusStatus
- type DSAModule
- type Dir
- type EventLog
- type EventLogIterator
- type ExecutionPhase
- type FeePayment
- type FeePaymentIterator
- type GenesisStorage
- type GenesisStorageWriter
- type GenesisType
- type JSONVersion
- type LogsBloom
- type MemberIterator
- type MemberList
- type MerkleNode
- type NTSDProofList
- type NTSHashEntryFormat
- type NTSHashEntryList
- type NetworkDigest
- type NetworkError
- type NetworkManager
- type NetworkSection
- type NetworkTransport
- type NetworkTypeDigest
- type NetworkTypeModule
- type NetworkTypeSection
- type NotRegisteredProtocolPolicy
- type OpType
- type Patch
- type PatchDecoder
- type PeerID
- type ProgressCallback
- type ProtocolHandler
- type ProtocolInfo
- type Reactor
- type Receipt
- type ReceiptIterator
- type ReceiptList
- type Regulator
- type Revision
- func (r Revision) AutoAcceptGovernance() bool
- func (r Revision) ExpandErrorCode() bool
- func (r Revision) Has(flag Revision) bool
- func (r Revision) InputCostingWithJSON() bool
- func (r Revision) LegacyBalanceCheck() bool
- func (r Revision) LegacyContentCount() bool
- func (r Revision) LegacyFallbackCheck() bool
- func (r Revision) LegacyFeeCharge() bool
- func (r Revision) UseChainID() bool
- func (r Revision) UseCompactAPIInfo() bool
- func (r Revision) UseMPTOnEvents() bool
- func (r Revision) Value() int
- type Role
- type SCOREStatus
- type ServiceManager
- type SkipTransactionPatch
- type Status
- type Timestamper
- type TraceBlock
- type TraceCallback
- type TraceInfo
- type TraceLevel
- type TraceMode
- type TraceRange
- type Transaction
- type TransactionGroup
- type TransactionInfo
- type TransactionIterator
- type TransactionList
- type Transition
- type TransitionCallback
- type TransitionManager
- type Validator
- type ValidatorList
- type Wallet
- type WalletProvider
- type ZeroNTSHashEntryList
Constants ¶
View Source
const ( BlockVersion0 = iota BlockVersion1 BlockVersion2 )
View Source
const ( DirLeft = Dir(iota) DirRight )
View Source
const ( TransactionVersion2 = 2 TransactionVersion3 = 3 )
View Source
const ( FlagNextProofContext = 0x1 FlagBTPBlockHeader = 0x2 FlagBTPBlockProof = 0x4 )
View Source
const ( NoRevision = 0 BackwardRevision = AutoAcceptGovernance | LegacyFeeCharge | LegacyFallbackCheck | LegacyContentCount | LegacyBalanceCheck | LegacyInputJSON | LegacyNoTimeout AllRevision = LastRevisionBit - 1 LatestRevision = AllRevision ^ BackwardRevision )
View Source
const ( FinalizeNormalTransaction = 1 << iota FinalizePatchTransaction FinalizeResult KeepingParent // TODO It's only necessary if storing receipt index is determined by // block manager. The current service manager determines by itself according // to version, so it doesn't use it. FinalizeWriteReceiptIndex )
Options for finalize
View Source
const (
ImportByForce = 0x1
)
View Source
const (
PatchTypeSkipTransaction = "skip_txs"
)
Variables ¶
This section is empty.
Functions ¶
func BlockDataToBytes ¶ added in v0.9.10
func GetSourceNetworkUID ¶ added in v1.3.0
func SourceNetworkUID ¶ added in v1.3.0
Types ¶
type APIInfo ¶
type APIInfo interface {
ToJSON(JSONVersion) (interface{}, error)
}
type BTPBlockHeader ¶ added in v1.3.0
type BTPBlockHeader interface { MainHeight() int64 Round() int32 NextProofContextHash() []byte NetworkSectionToRoot() []MerkleNode NetworkID() int64 UpdateNumber() int64 FirstMessageSN() int64 NextProofContextChanged() bool PrevNetworkSectionHash() []byte MessageCount() int64 MessagesRoot() []byte NextProofContext() []byte HeaderBytes() []byte }
type BTPDigest ¶ added in v1.3.0
type BTPDigest interface { Bytes() []byte Hash() []byte NetworkTypeDigests() []NetworkTypeDigest NetworkTypeDigestFor(ntid int64) NetworkTypeDigest // NetworkTypeIDFromNID returns ntid for nid in this digest. Returns // wrapped ErrNotFound if nid is not found in this digest. NetworkTypeIDFromNID(nid int64) (int64, error) // Flush writes this BTPDigest and its connected objects. // If a BTPDigest is created by a BTPSection and the BTPSection is created // by btp.SectionBuilder, the BTPDigest has all the BTPMessageList's and // the BTPMessage's in the section as its connected objects. Thus, they are // all written when Flush is called. In other cases, a BTPDigest has no // connected objects. Thus, only the BTPDigest itself is written when Flush // is called. Flush(dbase db.Database) error NetworkSectionFilter() BitSetFilter NTSHashEntryList // NTSVoteCount returns NTS vote count for this digest. // pcm is the nextPCM in block(h-1) where the digest is in block(h). NTSVoteCount(pcm BTPProofContextMap) (int, error) }
type BTPMessage ¶ added in v1.3.0
type BTPMessageList ¶ added in v1.3.0
type BTPNetwork ¶ added in v1.3.0
type BTPNetworkType ¶ added in v1.3.0
type BTPProof ¶ added in v1.3.0
type BTPProof interface { Bytes() []byte Add(pp BTPProofPart) ValidatorCount() int ProofPartAt(i int) BTPProofPart }
type BTPProofContext ¶ added in v1.3.0
type BTPProofContext interface { Hash() []byte Bytes() []byte NewProofPart(decisionHash []byte, wp WalletProvider) (BTPProofPart, error) NewProofPartFromBytes(ppBytes []byte) (BTPProofPart, error) VerifyPart(decisionHash []byte, pp BTPProofPart) (int, error) NewProof() BTPProof NewProofFromBytes(proofBytes []byte) (BTPProof, error) Verify(decisionHash []byte, p BTPProof) error DSA() string UID() string NewDecision( srcNetworkUID []byte, ntid int64, height int64, round int32, ntsHash []byte, ) BytesHasher }
type BTPProofContextMap ¶ added in v1.3.0
type BTPProofContextMap interface { ProofContextFor(ntid int64) (BTPProofContext, error) Update(src BTPProofContextMapUpdateSource) (BTPProofContextMap, error) Verify( srcUID []byte, height int64, round int32, bd BTPDigest, ntsdProves NTSDProofList, ) error }
type BTPProofContextMapUpdateSource ¶ added in v1.3.0
type BTPProofContextMapUpdateSource interface { BTPSection() (BTPSection, error) NextProofContextMap() (BTPProofContextMap, error) }
type BTPProofPart ¶ added in v1.3.0
type BTPProofPart interface {
Bytes() []byte
}
type BTPSection ¶ added in v1.3.0
type BTPSection interface { Digest() BTPDigest NetworkTypeSections() []NetworkTypeSection NetworkTypeSectionFor(ntid int64) (NetworkTypeSection, error) }
type BaseWallet ¶ added in v1.3.0
type BitSetFilter ¶ added in v1.3.0
type BitSetFilter struct {
// contains filtered or unexported fields
}
func BitSetFilterFromBytes ¶ added in v1.3.0
func BitSetFilterFromBytes(s []byte, capInBytes int) BitSetFilter
func MakeBitSetFilter ¶ added in v1.3.0
func MakeBitSetFilter(capInBytes int) BitSetFilter
func (BitSetFilter) Bytes ¶ added in v1.3.0
func (f BitSetFilter) Bytes() []byte
func (*BitSetFilter) Set ¶ added in v1.3.0
func (f *BitSetFilter) Set(idx int64)
func (BitSetFilter) Test ¶ added in v1.3.0
func (f BitSetFilter) Test(idx int64) bool
type Block ¶
type Block interface { BlockData NextValidators() ValidatorList // Copy returns goroutine safe copy Copy() Block BTPDigest() (BTPDigest, error) BTPSection() (BTPSection, error) NextProofContextMap() (BTPProofContextMap, error) }
type BlockCandidate ¶
type BlockCandidate interface { Block Dup() BlockCandidate Dispose() }
type BlockData ¶
type BlockData interface { Version() int ID() []byte Height() int64 PrevID() []byte NextValidatorsHash() []byte // Votes returns votes. Its voters are subset of previous-previous block's // next validators Votes() CommitVoteSet NormalTransactions() TransactionList PatchTransactions() TransactionList Timestamp() int64 Proposer() Address // can be nil. e.g. in genesis block. LogsBloom() LogsBloom Result() []byte MarshalHeader(w io.Writer) error MarshalBody(w io.Writer) error Marshal(w io.Writer) error ToJSON(version JSONVersion) (interface{}, error) NewBlock(tr Transition) Block Hash() []byte NetworkSectionFilter() BitSetFilter NTSHashEntryList() (NTSHashEntryList, error) BTPDigest() (BTPDigest, error) }
type BlockDataFactory ¶ added in v1.2.11
type BlockManager ¶
type BlockManager interface { GetBlockByHeight(height int64) (Block, error) GetLastBlock() (Block, error) GetBlock(id []byte) (Block, error) // WaitForBlock returns a channel that receives the block with the given // height. WaitForBlock(height int64) (<-chan Block, error) // NewBlockDataFromReader creates a BlockData from reader. The returned block // shall be imported by ImportBlock before it is Committed or Finalized. NewBlockDataFromReader(r io.Reader) (BlockData, error) // Propose proposes a Block following the parent Block. // The result is asynchronously notified by cb. canceler cancels the // operation. canceler returns true and cb is not called if the // cancellation was successful. The proposed block can be Committed or // Finalized. Propose( parentID []byte, votes CommitVoteSet, cb func(BlockCandidate, error), ) (canceler Canceler, err error) // Import creates a Block from blockBytes and verifies the block. // The result is asynchronously notified by cb. canceler cancels the // operation. canceler returns true and cb is not called if the // cancellation was successful. The imported block can be Committed or // Finalized. // Perform forced state sync if the transition's execution result and block // result does not match and flags' ImportByForce bit is on. Import(r io.Reader, flags int, cb func(BlockCandidate, error)) (canceler Canceler, err error) ImportBlock(blk BlockData, flags int, cb func(BlockCandidate, error)) (canceler Canceler, err error) // Finalize updates world state according to BlockCandidate and removes non-finalized committed blocks with the same height as block from persistent storage. Finalize(BlockCandidate) error GetTransactionInfo(id []byte) (TransactionInfo, error) Term() // WaitForTransaction waits for a transaction with timestamp between // bi.Timestamp() - TimestampThreshold and current time + // TimestampThreshold. If such a transaction is available now, the function // returns false and callback cb is not called. WaitForTransaction(parentID []byte, cb func()) (bool, error) // SendTransactionAndWait sends a transaction, and get a channel to // to wait for the result of it. SendTransactionAndWait(result []byte, height int64, txi interface{}) (tid []byte, rc <-chan interface{}, err error) // WaitTransactionResult check whether it knows about the transaction // and wait for the result. WaitTransactionResult(id []byte) (rc <-chan interface{}, err error) // ExportBlocks exports blocks assuring specified block ranges. ExportBlocks(from, to int64, dst db.Database, on ProgressCallback) error // ExportGenesis exports genesis to the writer based on the block. ExportGenesis(blk BlockData, votes CommitVoteSet, writer GenesisStorageWriter) error // GetGenesisData returns available votes from genesis storage. // They are available only when it starts from genesis. GetGenesisData() (Block, CommitVoteSet, error) // NewConsensusInfo returns a ConsensusInfo with proposer of previous block // of blk and votes in blk. NewConsensusInfo(blk Block) (ConsensusInfo, error) }
type BroadcastType ¶
type BroadcastType byte
const ( BroadcastAll BroadcastType = iota BroadcastNeighbor BroadcastChildren )
func (BroadcastType) ForceSend ¶
func (b BroadcastType) ForceSend() bool
func (BroadcastType) TTL ¶
func (b BroadcastType) TTL() byte
type BytesHasher ¶ added in v1.3.0
type BytesSlice ¶ added in v1.3.0
type BytesSlice [][]byte
func (*BytesSlice) Get ¶ added in v1.3.0
func (b *BytesSlice) Get(i int) []byte
func (*BytesSlice) Len ¶ added in v1.3.0
func (b *BytesSlice) Len() int
type Chain ¶
type Chain interface { Database() db.Database DoDBTask(func(database db.Database)) Wallet() Wallet NID() int CID() int NetID() int Channel() string ConcurrencyLevel() int NormalTxPoolSize() int PatchTxPoolSize() int MaxBlockTxBytes() int DefaultWaitTimeout() time.Duration MaxWaitTimeout() time.Duration TransactionTimeout() time.Duration ChildrenLimit() int NephewsLimit() int ValidateTxOnSend() bool Genesis() []byte GenesisStorage() GenesisStorage CommitVoteSetDecoder() CommitVoteSetDecoder PatchDecoder() PatchDecoder PlatformName() string BlockManager() BlockManager Consensus() Consensus ServiceManager() ServiceManager NetworkManager() NetworkManager Regulator() Regulator Init() error Start() error Stop() error Import(src string, height int64) error Prune(gs string, dbt string, height int64) error Backup(file string, extra []string) error RunTask(task string, params json.RawMessage) error Term() error State() (string, int64, error) IsStarted() bool IsStopped() bool // Reset resets chain. height must be 0 or greater than 1. // If height == 0, blockHash shall be nil or zero length // bytes and the function cleans up database and file systems for the chain. // If height > 1, blockHash shall be the hash of correct block with the // height and the function cleans up database and file systems for the chain // and prepare pruned genesis block of the height. Reset(gs string, height int64, blockHash []byte) error Verify() error MetricContext() context.Context Logger() log.Logger WalletFor(dsa string) BaseWallet }
type CommitVoteSet ¶
type CommitVoteSet interface { // VerifyBlock verifies a block with block votes VerifyBlock(block BlockData, validators ValidatorList) ([]bool, error) BlockVoteSetBytes() []byte Bytes() []byte Hash() []byte Timestamp() int64 // VoteRound returns vote round if it is for block version >= 2. In other // case, the value is ignored. VoteRound() int32 NTSDProofList }
type CommitVoteSetDecoder ¶
type CommitVoteSetDecoder func([]byte) CommitVoteSet
type Consensus ¶
type Consensus interface { Start() error Term() GetStatus() *ConsensusStatus GetVotesByHeight(height int64) (CommitVoteSet, error) // GetBTPBlockHeaderAndProof returns header and proof according to the given // flag. GetBTPBlockHeaderAndProof( blk Block, nid int64, flag uint, ) (btpBlk BTPBlockHeader, proof []byte, err error) }
type ConsensusInfo ¶ added in v0.9.4
type ConsensusInfo interface { Proposer() Address Voters() ValidatorList Voted() []bool }
type ConsensusStatus ¶
type EventLogIterator ¶
type ExecutionPhase ¶ added in v1.2.13
type ExecutionPhase int
const ( EPhaseTransaction ExecutionPhase = iota EPhaseExecutionEnd )
type FeePayment ¶ added in v0.9.6
type FeePaymentIterator ¶ added in v0.9.6
type FeePaymentIterator interface { Has() bool Next() error Get() (FeePayment, error) }
type GenesisStorage ¶
type GenesisStorageWriter ¶
type GenesisType ¶
type GenesisType int
const ( GenesisUnknown GenesisType = iota GenesisNormal GenesisPruned )
type JSONVersion ¶
type JSONVersion int
const ( JSONVersion2 JSONVersion = iota JSONVersion3 JSONVersion3Raw JSONVersionLast = JSONVersion3Raw )
type MemberIterator ¶
type MemberList ¶
type MemberList interface { IsEmpty() bool Equal(MemberList) bool Iterator() MemberIterator }
type MerkleNode ¶ added in v1.3.0
type NTSDProofList ¶ added in v1.3.0
type NTSHashEntryFormat ¶ added in v1.3.0
type NTSHashEntryList ¶ added in v1.3.0
type NTSHashEntryList interface { NTSHashEntryListFormat() []NTSHashEntryFormat NTSHashEntryCount() int NTSHashEntryAt(i int) NTSHashEntryFormat }
type NetworkDigest ¶ added in v1.3.0
type NetworkDigest interface { NetworkID() int64 NetworkSectionHash() []byte MessagesRoot() []byte MessageList(dbase db.Database, mod NetworkTypeModule) (BTPMessageList, error) }
type NetworkError ¶
type NetworkManager ¶
type NetworkManager interface { Start() error Term() GetPeers() []PeerID RegisterReactor(name string, pi ProtocolInfo, reactor Reactor, piList []ProtocolInfo, priority uint8, policy NotRegisteredProtocolPolicy) (ProtocolHandler, error) RegisterReactorForStreams(name string, pi ProtocolInfo, reactor Reactor, piList []ProtocolInfo, priority uint8, policy NotRegisteredProtocolPolicy) (ProtocolHandler, error) UnregisterReactor(reactor Reactor) error SetRole(version int64, role Role, peers ...PeerID) GetPeersByRole(role Role) []PeerID AddRole(role Role, peers ...PeerID) RemoveRole(role Role, peers ...PeerID) HasRole(role Role, id PeerID) bool Roles(id PeerID) []Role SetTrustSeeds(seeds string) SetInitialRoles(roles ...Role) }
type NetworkSection ¶ added in v1.3.0
type NetworkTransport ¶
type NetworkTransport interface { Listen() error Close() error Dial(address string, channel string) error PeerID() PeerID Address() string SetListenAddress(address string) error GetListenAddress() string SetSecureSuites(channel string, secureSuites string) error GetSecureSuites(channel string) string SetSecureAeads(channel string, secureAeads string) error GetSecureAeads(channel string) string }
type NetworkTypeDigest ¶ added in v1.3.0
type NetworkTypeDigest interface { NetworkTypeID() int64 UID() string NetworkTypeSectionHash() []byte NetworkDigests() []NetworkDigest NetworkDigestFor(nid int64) NetworkDigest NetworkSectionsRootWithMod(mod NetworkTypeModule) []byte NetworkSectionToRootWithMod(mod NetworkTypeModule, nid int64) ([]MerkleNode, error) }
type NetworkTypeModule ¶ added in v1.3.0
type NetworkTypeModule interface { UID() string Hash(data []byte) []byte AppendHash(out []byte, data []byte) []byte DSA() string NewProofContextFromBytes(bs []byte) (BTPProofContext, error) // NewProofContext returns a new proof context. The parameter keys is // a slice of networkType specific keys (usually a slice of addresses). NewProofContext(keys [][]byte) (BTPProofContext, error) MerkleRoot(bytesList BytesList) []byte MerkleProof(bytesList BytesList, idx int) []MerkleNode AddressFromPubKey(pubKey []byte) ([]byte, error) BytesByHashBucket() db.BucketID ListByMerkleRootBucket() db.BucketID NewProofFromBytes(bs []byte) (BTPProof, error) NetworkTypeKeyFromDSAKey(key []byte) ([]byte, error) DSAModule() DSAModule }
type NetworkTypeSection ¶ added in v1.3.0
type NetworkTypeSection interface { NetworkTypeID() int64 Hash() []byte NetworkSectionsRoot() []byte NetworkSectionToRoot(nid int64) ([]MerkleNode, error) NextProofContext() BTPProofContext NetworkSectionFor(nid int64) (NetworkSection, error) NewDecision(srcNetworkUID []byte, height int64, round int32) BytesHasher }
type NotRegisteredProtocolPolicy ¶ added in v1.2.9
type NotRegisteredProtocolPolicy byte
const ( NotRegisteredProtocolPolicyNone NotRegisteredProtocolPolicy = iota NotRegisteredProtocolPolicyDrop NotRegisteredProtocolPolicyClose )
type ProgressCallback ¶ added in v1.3.2
ProgressCallback is used to report progress of sync task. "height" is the height to the block to sync. "resolved" is number of already synced items. "unresolved" is number of known items to be synced. More items can be added to "unresolved" after syncing known items. Some of items may not be counted.
type ProtocolHandler ¶
type ProtocolHandler interface { Broadcast(pi ProtocolInfo, b []byte, bt BroadcastType) error Multicast(pi ProtocolInfo, b []byte, role Role) error Unicast(pi ProtocolInfo, b []byte, id PeerID) error GetPeers() []PeerID }
type ProtocolInfo ¶
type ProtocolInfo uint16
const ( ProtoP2P ProtocolInfo = iota << 8 ProtoStateSync ProtoTransaction ProtoConsensus ProtoFastSync ProtoConsensusSync ProtoReserved )
func NewProtocolInfo ¶
func NewProtocolInfo(id byte, version byte) ProtocolInfo
func (ProtocolInfo) ID ¶
func (pi ProtocolInfo) ID() byte
func (ProtocolInfo) String ¶
func (pi ProtocolInfo) String() string
func (ProtocolInfo) Uint16 ¶
func (pi ProtocolInfo) Uint16() uint16
func (ProtocolInfo) Version ¶
func (pi ProtocolInfo) Version() byte
type Receipt ¶
type Receipt interface { Bytes() []byte To() Address CumulativeStepUsed() *big.Int StepPrice() *big.Int StepUsed() *big.Int Status() Status SCOREAddress() Address Check(r Receipt) error ToJSON(version JSONVersion) (interface{}, error) LogsBloom() LogsBloom BTPMessages() *list.List EventLogIterator() EventLogIterator FeePaymentIterator() FeePaymentIterator LogsBloomDisabled() bool GetProofOfEvent(int) ([][]byte, error) }
type ReceiptIterator ¶
type ReceiptList ¶
type Revision ¶ added in v0.9.1
type Revision int64
const ( InputCostingWithJSON Revision = 1 << (8 + iota) ExpandErrorCode UseChainID UseMPTOnEvents UseCompactAPIInfo AutoAcceptGovernance LegacyFeeCharge LegacyFallbackCheck LegacyContentCount LegacyBalanceCheck LegacyInputJSON LegacyNoTimeout FixLostFeeByDeposit MultipleFeePayers PurgeEnumCache ContractSetEvent FixMapValues LastRevisionBit )
func (Revision) AutoAcceptGovernance ¶ added in v0.9.6
func (Revision) ExpandErrorCode ¶ added in v0.9.1
func (Revision) InputCostingWithJSON ¶ added in v0.9.1
func (Revision) LegacyBalanceCheck ¶ added in v0.9.6
func (Revision) LegacyContentCount ¶ added in v0.9.6
func (Revision) LegacyFallbackCheck ¶ added in v0.9.6
func (Revision) LegacyFeeCharge ¶ added in v0.9.10
func (Revision) UseChainID ¶ added in v0.9.1
func (Revision) UseCompactAPIInfo ¶ added in v0.9.1
func (Revision) UseMPTOnEvents ¶ added in v0.9.1
type SCOREStatus ¶ added in v1.2.11
type SCOREStatus interface {
ToJSON(height int64, version JSONVersion) (interface{}, error)
}
type ServiceManager ¶
type ServiceManager interface { TransitionManager // Start starts service module. Start() // Term terminates serviceManager instance. Term() // TransactionFromBytes returns a Transaction instance from bytes. TransactionFromBytes(b []byte, blockVersion int) (Transaction, error) // GenesisTransactionFromBytes returns a Genesis Transaction instance from bytes. GenesisTransactionFromBytes(b []byte, blockVersion int) (Transaction, error) // TransactionListFromHash returns a TransactionList instance from // the hash of transactions or nil when no transactions exist. // It assumes it's called only by new version block, so it doesn't receive // version value. TransactionListFromHash(hash []byte) TransactionList // TransactionListFromSlice returns list of transactions. TransactionListFromSlice(txs []Transaction, version int) TransactionList // ReceiptListFromResult returns list of receipts from result. ReceiptListFromResult(result []byte, g TransactionGroup) (ReceiptList, error) // SendTransaction adds transaction to a transaction pool. SendTransaction(result []byte, height int64, tx interface{}) ([]byte, error) // SendPatch sends a patch SendPatch(patch Patch) error // Call handles read-only contract API call. Call(result []byte, vl ValidatorList, js []byte, bi BlockInfo) (interface{}, error) // ValidatorListFromHash returns ValidatorList from hash. ValidatorListFromHash(hash []byte) ValidatorList // GetBalance returns balance of the account GetBalance(result []byte, addr Address) (*big.Int, error) // GetTotalSupply returns total supplied coin GetTotalSupply(result []byte) (*big.Int, error) // GetNetworkID returns network ID of the state GetNetworkID(result []byte) (int64, error) // GetChainID returns chain ID of the state GetChainID(result []byte) (int64, error) // GetAPIInfo returns API info of the contract GetAPIInfo(result []byte, addr Address) (APIInfo, error) // GetSCOREStatus returns status of the contract GetSCOREStatus(result []byte, addr Address) (SCOREStatus, error) // GetMembers returns network member list GetMembers(result []byte) (MemberList, error) // GetRoundLimit returns round limit GetRoundLimit(result []byte, vl int) int64 // GetStepPrice returns the step price of the state GetStepPrice(result []byte) (*big.Int, error) // GetMinimizeBlockGen returns minimize empty block generation flag GetMinimizeBlockGen(result []byte) bool // GetNextBlockVersion returns version of next block GetNextBlockVersion(result []byte) int // BTPSectionFromResult returns BTPSection for the result BTPSectionFromResult(result []byte) (BTPSection, error) // BTPDigestFromResult returns BTPDigest for the result BTPDigestFromResult(result []byte) (BTPDigest, error) // NextProofContextMapFromResult returns BTPProofContextMap for the result NextProofContextMapFromResult(result []byte) (BTPProofContextMap, error) BTPNetworkTypeFromResult(result []byte, ntid int64) (BTPNetworkType, error) BTPNetworkFromResult(result []byte, nid int64) (BTPNetwork, error) BTPNetworkTypeIDsFromResult(result []byte) ([]int64, error) // HasTransaction returns whether it has specified transaction in the pool HasTransaction(id []byte) bool // SendTransactionAndWait send transaction and return channel for result SendTransactionAndWait(result []byte, height int64, tx interface{}) ([]byte, <-chan interface{}, error) // WaitTransactionResult return channel for result. WaitTransactionResult(id []byte) (<-chan interface{}, error) // ExportResult exports all related entries related with the result // should be exported to the database ExportResult(result []byte, vh []byte, dst db.Database) error // ImportResult imports all related entries related with the result // should be imported from the database ImportResult(result []byte, vh []byte, src db.Database) error // ExecuteTransaction executes the transaction on the specified state. // Then it returns the expected result of the transaction. // It ignores supplied step limit. ExecuteTransaction(result []byte, vh []byte, js []byte, bi BlockInfo) (Receipt, error) // AddSyncRequest add sync request for specified data. AddSyncRequest(id db.BucketID, key []byte) error }
type SkipTransactionPatch ¶
type Status ¶
type Status int
const ( StatusSuccess Status = iota StatusUnknownFailure StatusContractNotFound StatusMethodNotFound StatusMethodNotPayable StatusIllegalFormat StatusInvalidParameter StatusInvalidInstance StatusInvalidContainerAccess StatusAccessDenied StatusOutOfStep StatusOutOfBalance StatusTimeout StatusStackOverflow StatusSkipTransaction StatusInvalidPackage StatusReverted Status = 32 StatusLimitRev5 Status = 99 StatusLimit Status = 999 )
type Timestamper ¶
type TraceBlock ¶ added in v1.2.13
type TraceCallback ¶
type TraceCallback interface { OnLog(level TraceLevel, msg string) OnEnd(e error) OnTransactionStart(txIndex int, txHash []byte, isBlockTx bool) error OnTransactionReset() error OnTransactionEnd(txIndex int, txHash []byte) error OnFrameEnter() error OnFrameExit(success bool) error OnBalanceChange(opType OpType, from, to Address, amount *big.Int) error }
type TraceInfo ¶
type TraceInfo struct { TraceMode TraceMode TraceBlock TraceBlock Range TraceRange // Group and Index are valid only if Range is TraceRangeTransaction Group TransactionGroup Index int Callback TraceCallback }
type TraceLevel ¶
type TraceLevel int
const ( TDebugLevel TraceLevel = iota TTraceLevel TSystemLevel )
type TraceRange ¶ added in v1.2.13
type TraceRange int
const ( TraceRangeBlock TraceRange = iota TraceRangeTransaction TraceRangeBlockTransaction )
type Transaction ¶
type TransactionGroup ¶
type TransactionGroup int
const ( TransactionGroupPatch TransactionGroup = iota TransactionGroupNormal )
type TransactionInfo ¶
type TransactionInfo interface { Block() Block Index() int Group() TransactionGroup Transaction() (Transaction, error) GetReceipt() (Receipt, error) }
type TransactionIterator ¶
type TransactionIterator interface { Has() bool Next() error Get() (Transaction, int, error) }
type TransactionList ¶
type TransactionList interface { Get(int) (Transaction, error) Iterator() TransactionIterator // length if Hash() is 0 iff empty Hash() []byte Equal(TransactionList) bool Flush() error }
type Transition ¶
type Transition interface { PatchTransactions() TransactionList NormalTransactions() TransactionList PatchReceipts() ReceiptList NormalReceipts() ReceiptList // Execute executes this transition. // The result is asynchronously notified by cb. canceler can be used // to cancel it after calling Execute. After canceler returns true, // all succeeding cb functions may not be called back. // REMARK: It is assumed to be called once. Any additional call returns // error. Execute(cb TransitionCallback) (canceler func() bool, err error) // ExecuteForTrace executes this transition until it executes the transaction // at offset `n` of normal transactions. If it fails, then OnValidate or // OnExecute will be called with an error. ExecuteForTrace(ti TraceInfo) (canceler func() bool, err error) // Result returns service manager defined result bytes. // For example, it can be "[world_state_hash][patch_tx_hash][normal_tx_hash]". Result() []byte // NextValidators returns the addresses of validators as a result of // transaction processing. // It may return nil before cb.OnExecute is called back by Execute. NextValidators() ValidatorList // LogsBloom returns log bloom filter for this transition. // It may return nil before cb.OnExecute is called back by Execute. LogsBloom() LogsBloom // BlockInfo returns block information for the normal transaction. BlockInfo() BlockInfo // Equal check equality of inputs of transition. Equal(Transition) bool // BTPSection returns the BTPSection as a result of transaction processing. // It may return empty one before cb.OnExecute is called back by Execute. BTPSection() BTPSection }
type TransitionCallback ¶
type TransitionCallback interface { // Called if validation is done. OnValidate(Transition, error) // Called if execution is done. OnExecute(Transition, error) }
TransitionCallback provides transition change notifications. All functions are called back with the same Transition instance for the convenience.
type TransitionManager ¶
type TransitionManager interface { // ProposeTransition proposes a Transition following the parent Transition. // Returned Transition always passes validation. ProposeTransition(parent Transition, bi BlockInfo, csi ConsensusInfo) (Transition, error) // CreateInitialTransition creates an initial Transition. CreateInitialTransition(result []byte, nextValidators ValidatorList) (Transition, error) // CreateTransition creates a Transition following parent Transition. CreateTransition(parent Transition, txs TransactionList, bi BlockInfo, csi ConsensusInfo, validated bool) (Transition, error) // GetPatches returns all patch transactions based on the parent transition. // bi is the block info of the block that will contain the patches GetPatches(parent Transition, bi BlockInfo) TransactionList // PatchTransition creates a Transition by overwriting patches on the transition. // bi is the block info of the block that contains the patches, // or nil if the patches are already prevalidated. PatchTransition(transition Transition, patches TransactionList, bi BlockInfo) Transition CreateSyncTransition(transition Transition, result []byte, vlHash []byte, noBuffer bool) Transition // Finalize finalizes data related to the transition. It usually stores // data to a persistent storage. opt indicates which data are finalized. // It should be called for every transition. Finalize(transition Transition, opt int) error // WaitTransaction waits for a transaction with timestamp between // bi.Timestamp() - TimestampThreshold and current time + // TimestampThreshold. If such a transaction is available now, the function // returns false and callback cb is not called. WaitForTransaction(parent Transition, bi BlockInfo, cb func()) bool }
TransitionManager provides Transition APIs. For a block proposal, it is usually called as follows:
- GetPatches
- if any changes of patches exist from GetPatches 2.1 PatchTransaction 2.2 Transition.Execute
- ProposeTransition
- Transition.Execute
For a block validation,
- if any changes of patches are detected from a new block 1.1 PatchTransition 1.2 Transition.Execute
- create Transaction instances by TransactionFromBytes
- CreateTransition with TransactionList
- Transition.Execute
type ValidatorList ¶
type Wallet ¶
type Wallet interface { BaseWallet Address() Address }
type WalletProvider ¶ added in v1.3.0
type WalletProvider interface { // WalletFor returns public key for dsa. WalletFor(dsa string) BaseWallet }
type ZeroNTSHashEntryList ¶ added in v1.3.0
type ZeroNTSHashEntryList struct { }
func (ZeroNTSHashEntryList) NTSHashEntryAt ¶ added in v1.3.0
func (z ZeroNTSHashEntryList) NTSHashEntryAt(i int) NTSHashEntryFormat
func (ZeroNTSHashEntryList) NTSHashEntryCount ¶ added in v1.3.0
func (z ZeroNTSHashEntryList) NTSHashEntryCount() int
func (ZeroNTSHashEntryList) NTSHashEntryListFormat ¶ added in v1.3.0
func (z ZeroNTSHashEntryList) NTSHashEntryListFormat() []NTSHashEntryFormat
Click to show internal directories.
Click to hide internal directories.