Documentation
¶
Index ¶
- type Account
- type Batch
- type ChunkReader
- type ConsensusVerifier
- type DBStatus
- type EventListener
- type GenResult
- type Generator
- type IncomingMessage
- type LedgerReader
- type LoadOnroadFn
- type Segment
- type SegmentList
- type SignFunc
- type StateSnapshot
- type StorageIterator
- type Store
- type SyncCache
- type TimeIndex
- type VerifyFunc
- type VmAccountBlock
- type VmDb
- type VoteDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChunkReader ¶
type ChunkReader interface {
// Read a block, return io.EOF if reach end, the block maybe a accountBlock or a snapshotBlock
Read() (accountBlock *core.AccountBlock, snapshotBlock *core.SnapshotBlock, err error)
// Close the stream
Close() error
Size() int64
Verified() bool
Verify()
}
type ConsensusVerifier ¶ added in v2.11.3
type ConsensusVerifier interface {
VerifyAccountProducer(block *core.AccountBlock) (bool, error)
VerifyABsProducer(abs map[types.Gid][]*core.AccountBlock) ([]*core.AccountBlock, error)
VerifySnapshotProducer(block *core.SnapshotBlock) (bool, error)
}
ConsensusVerifier is the interface that can verify block consensus.
type EventListener ¶ added in v2.11.3
type EventListener interface {
PrepareInsertAccountBlocks(blocks []*VmAccountBlock) error
InsertAccountBlocks(blocks []*VmAccountBlock) error
PrepareInsertSnapshotBlocks(chunks []*core.SnapshotChunk) error
InsertSnapshotBlocks(chunks []*core.SnapshotChunk) error
PrepareDeleteAccountBlocks(blocks []*core.AccountBlock) error
DeleteAccountBlocks(blocks []*core.AccountBlock) error
PrepareDeleteSnapshotBlocks(chunks []*core.SnapshotChunk) error
DeleteSnapshotBlocks(chunks []*core.SnapshotChunk) error
}
type GenResult ¶
type GenResult struct {
VMBlock *VmAccountBlock
IsRetry bool
Err error
}
GenResult represents the result of a block being validated by vm.
type Generator ¶
type Generator interface {
GenerateWithBlock(block *core.AccountBlock, fromBlock *core.AccountBlock) (*GenResult, error)
GenerateWithMessage(message *IncomingMessage, producer *types.Address, signFunc SignFunc) (*GenResult, error)
GenerateWithOnRoad(sendBlock *core.AccountBlock, producer *types.Address, signFunc SignFunc, difficulty *big.Int) (*GenResult, error)
GetVMDB() VmDb
}
type IncomingMessage ¶
type IncomingMessage struct {
BlockType byte
AccountAddress types.Address
ToAddress *types.Address
FromBlockHash *types.Hash
TokenId *types.TokenTypeId
Amount *big.Int
Fee *big.Int
Data []byte
Difficulty *big.Int
}
IncomingMessage carries the necessary transaction info.
type LedgerReader ¶
type LedgerReader interface {
Seg() Segment
Size() int
io.ReadCloser
}
type LoadOnroadFn ¶ added in v2.11.3
type LoadOnroadFn func(fromAddr, toAddr types.Address, hashHeight core.HashHeight) error
type Segment ¶
type SegmentList ¶
type SegmentList []Segment
func (SegmentList) Len ¶
func (list SegmentList) Len() int
func (SegmentList) Less ¶
func (list SegmentList) Less(i, j int) bool
func (SegmentList) Swap ¶
func (list SegmentList) Swap(i, j int)
type SignFunc ¶
SignFunc is the function type defining the callback when a block requires a method to sign the transaction in generator.
type StateSnapshot ¶
type StateSnapshot interface {
// ====== balance ======
GetBalance(tokenId *types.TokenTypeId) (*big.Int, error)
// ====== Storage ======
GetValue([]byte) ([]byte, error)
NewStorageIterator(prefix []byte) StorageIterator
Release()
}
type StorageIterator ¶
type SyncCache ¶
type SyncCache interface {
NewWriter(segment Segment, size int64) (io.WriteCloser, error)
Chunks() SegmentList
NewReader(segment Segment) (ChunkReader, error)
Delete(seg Segment) error
Close() error
}
type VerifyFunc ¶
VerifyFunc is the function
type VmAccountBlock ¶
type VmAccountBlock struct {
AccountBlock *core.AccountBlock
VmDb VmDb
}
type VmDb ¶
type VmDb interface {
// ====== Context ======
CanWrite() bool
Address() *types.Address
LatestSnapshotBlock() (*core.SnapshotBlock, error)
PrevAccountBlock() (*core.AccountBlock, error)
GetLatestAccountBlock(addr types.Address) (*core.AccountBlock, error)
GetCallDepth(sendBlockHash *types.Hash) (uint16, error)
GetQuotaUsedList(addr types.Address) []types.QuotaInfo
GetGlobalQuota() types.QuotaInfo
// ====== State ======
GetReceiptHash() *types.Hash
Reset()
// Release memory used in runtime.
Finish()
// ====== Storage ======
GetValue(key []byte) ([]byte, error)
GetOriginalValue(key []byte) ([]byte, error)
SetValue(key []byte, value []byte) error
NewStorageIterator(prefix []byte) (StorageIterator, error)
GetUnsavedStorage() [][2][]byte
// ====== Balance ======
GetBalance(tokenTypeId *types.TokenTypeId) (*big.Int, error)
SetBalance(tokenTypeId *types.TokenTypeId, amount *big.Int)
GetUnsavedBalanceMap() map[types.TokenTypeId]*big.Int
// ====== VMLog ======
AddLog(log *core.VmLog)
GetLogList() core.VmLogList
GetHistoryLogList(logHash *types.Hash) (core.VmLogList, error)
GetLogListHash() *types.Hash
// ====== AccountBlock ======
GetUnconfirmedBlocks(address types.Address) []*core.AccountBlock
// ====== SnapshotBlock ======
GetGenesisSnapshotBlock() *core.SnapshotBlock
GetConfirmSnapshotHeader(blockHash types.Hash) (*core.SnapshotBlock, error)
GetConfirmedTimes(blockHash types.Hash) (uint64, error)
GetSnapshotBlockByHeight(height uint64) (*core.SnapshotBlock, error)
// ====== Meta & Code ======
SetContractMeta(toAddr types.Address, meta *core.ContractMeta)
GetContractMeta() (*core.ContractMeta, error)
GetContractMetaInSnapshot(contractAddress types.Address, snapshotBlock *core.SnapshotBlock) (meta *core.ContractMeta, err error)
SetContractCode(code []byte)
GetContractCode() ([]byte, error)
GetContractCodeBySnapshotBlock(addr *types.Address, snapshotBlock *core.SnapshotBlock) ([]byte, error) // TODO
GetUnsavedContractMeta() map[types.Address]*core.ContractMeta
GetUnsavedContractCode() []byte
// ====== built-in contract ======
GetStakeBeneficialAmount(addr *types.Address) (*big.Int, error)
// ====== debug ======
DebugGetStorage() (map[string][]byte, error)
}
Click to show internal directories.
Click to hide internal directories.