Documentation ¶
Index ¶
- Variables
- func AppendBloom(bin *etypes.Bloom, receipts etypes.Receipts)
- func BlockLogsBloom(cn *chain.Chain, b *types.Block) (etypes.Bloom, error)
- func CreateEventBloom(provider types.Provider, events []*ctypes.Event) (etypes.Bloom, error)
- func EventsToFullLogs(chain *chain.Chain, header *mtypes.Header, tx *mtypes.Transaction, ...) ([]*types.Log, error)
- func Exec(ctx *types.Context, user common.Address, contAddr common.Address, ...) ([]interface{}, error)
- func Exp(a, b *big.Int) *big.Int
- func FilterLogs(cn *chain.Chain, ts IBlockHeight, bs *BloomBitService, crit FilterQuery) ([]*types.Log, error)
- func FindCallHistoryEvents(evs []*ctypes.Event, idx uint16) ([]*ctypes.Event, error)
- func GetCC(ctx *types.Context, contAddr common.Address, user common.Address) (*types.ContractContext, error)
- func NewTestBlockChain(path string, deletePath bool, chainID *big.Int, version uint16, ...) (*testBlockChain, error)
- func RegisterContracts() map[string]uint64
- func Sub(a, b *big.Int) *big.Int
- func ToAmount(b *big.Int) *amount.Amount
- func TokenApprove(ctx *types.Context, token, owner, spender common.Address) error
- func TxLogsBloom(cn *chain.Chain, b *types.Block, idx uint16, receipt *etypes.Receipt) (etypes.Bloom, []*etypes.Log, error)
- type BloomBitService
- func (b *BloomBitService) BloomStatus() (uint64, uint64)
- func (b *BloomBitService) Close() error
- func (b *BloomBitService) Name() string
- func (b *BloomBitService) OnBlockConnected(block *types.Block, loader types.Loader)
- func (b *BloomBitService) OnLoadChain(loader types.Loader) error
- func (b *BloomBitService) OnTransactionFail(height uint32, txs []*types.Transaction, err []error)
- func (b *BloomBitService) OnTransactionInPoolExpired(txs []*types.Transaction)
- func (b *BloomBitService) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
- type BloomIndexer
- func (b *BloomIndexer) Commit() error
- func (b *BloomIndexer) OpenDatabase(path string, cache, handles int, namespace string, readonly bool) (ethdb.Database, error)
- func (b *BloomIndexer) Process(ctx context.Context, block *mtypes.Block) error
- func (b *BloomIndexer) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error
- type ChainIndexer
- type ChainIndexerBackend
- type Filter
- type FilterQuery
- type IBlockHeight
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AppendBloom ¶
AppendBloom appends the given Receipts (+Logs) to bloom
func BlockLogsBloom ¶
BlockLogsBloom retrurn block's logsBloom
func CreateEventBloom ¶
CreateEventBloom creates a bloom filter from the given go-type contract events
func EventsToFullLogs ¶
func EventsToFullLogs(chain *chain.Chain, header *mtypes.Header, tx *mtypes.Transaction, evs []*ctypes.Event, idx uint16) ([]*types.Log, error)
EventsToLogs converts non-evm type events to ethereum type logs
func Exec ¶
func Exec(ctx *types.Context, user common.Address, contAddr common.Address, methodName string, args []interface{}) ([]interface{}, error)
Exec calls ContractContext.Exec from Context
func FilterLogs ¶
func FilterLogs(cn *chain.Chain, ts IBlockHeight, bs *BloomBitService, crit FilterQuery) ([]*types.Log, error)
func FindCallHistoryEvents ¶
findTransactionsEvents find tx's EventTagCallHistory-type events from given event list
func GetCC ¶
func GetCC(ctx *types.Context, contAddr common.Address, user common.Address) (*types.ContractContext, error)
GetCC gets ContractContext from Contex with given contract address and user address
func NewTestBlockChain ¶
func NewTestBlockChain(path string, deletePath bool, chainID *big.Int, version uint16, genesis *types.Context, admin common.Address, cfg *initContextInfo, classMap map[string]uint64) (*testBlockChain, error)
NewTestBlockChain makes new test blockchain
func RegisterContracts ¶
RegisterContracts creates classmap for deploying contracts ususally in genesis
func TokenApprove ¶
TokenApprove call token.Apporve(to,Amount) from Context
Types ¶
type BloomBitService ¶
type BloomBitService struct {
// contains filtered or unexported fields
}
func NewBloomBitService ¶
func NewBloomBitService(cn *chain.Chain, path string, size, confirms uint64) (*BloomBitService, error)
NewBloomBitService starts a bloom service that performs bloom bit indexer and returns it
func (*BloomBitService) BloomStatus ¶
func (b *BloomBitService) BloomStatus() (uint64, uint64)
BloomStatus retrives the bloom size and sections
func (*BloomBitService) Name ¶
func (b *BloomBitService) Name() string
Name returns the name of the service
func (*BloomBitService) OnBlockConnected ¶
func (b *BloomBitService) OnBlockConnected(block *types.Block, loader types.Loader)
OnBlockConnected called when a block is connected to the chain
func (*BloomBitService) OnLoadChain ¶
func (b *BloomBitService) OnLoadChain(loader types.Loader) error
OnLoadChain called when the chain loaded
func (*BloomBitService) OnTransactionFail ¶
func (b *BloomBitService) OnTransactionFail(height uint32, txs []*types.Transaction, err []error)
OnTransactionFail called when a transaction in pool is expired
func (*BloomBitService) OnTransactionInPoolExpired ¶
func (b *BloomBitService) OnTransactionInPoolExpired(txs []*types.Transaction)
OnTransactionInPoolExpired called when a transaction in pool is expired
func (*BloomBitService) ServiceFilter ¶
func (b *BloomBitService) ServiceFilter(ctx context.Context, session *bloombits.MatcherSession)
type BloomIndexer ¶
type BloomIndexer struct {
// contains filtered or unexported fields
}
BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the Ethereum header bloom filters, permitting blazing fast filtering.
func (*BloomIndexer) Commit ¶
func (b *BloomIndexer) Commit() error
Commit implements core.ChainIndexerBackend, finalizing the bloom section and writing it out into the database.
func (*BloomIndexer) OpenDatabase ¶
func (b *BloomIndexer) OpenDatabase(path string, cache, handles int, namespace string, readonly bool) (ethdb.Database, error)
OpenDatabase opens an existing database with the given name (or creates one if no previous can be found) from within the node's instance directory. If the node is ephemeral, a memory database is returned.
type ChainIndexer ¶
type ChainIndexer struct {
// contains filtered or unexported fields
}
ChainIndexer does a post-processing job for equally sized sections of the canonical chain (like BlooomBits and CHT structures). A ChainIndexer is connected to the blockchain through the event system by starting a ChainHeadEventLoop in a goroutine.
Further child ChainIndexers can be added which use the output of the parent section indexer. These child indexers receive new head notifications only after an entire section has been finished or in case of rollbacks that might affect already finished sections.
func NewBloomIndexer ¶
NewBloomIndexer returns a bloom indexer that generates bloom bits data for the canonical chain for fast logs filtering.
func NewChainIndexer ¶
func NewChainIndexer(cn *chain.Chain, chainDb ethdb.Database, indexDb ethdb.Database, backend ChainIndexerBackend, section, confirm uint64, throttling time.Duration, kind string) *ChainIndexer
NewChainIndexer creates a new chain indexer to do background processing on chain segments of a given size after certain number of confirmations passed. The throttling parameter might be used to prevent database thrashing.
func (*ChainIndexer) AddCheckpoint ¶
func (c *ChainIndexer) AddCheckpoint(section uint64, shead common.Hash)
AddCheckpoint adds a checkpoint. Sections are never processed and the chain is not expected to be available before this point. The indexer assumes that the backend has sufficient information available to process subsequent sections.
Note: knownSections == 0 and storedSections == checkpointSections until syncing reaches the checkpoint
func (*ChainIndexer) Close ¶
func (c *ChainIndexer) Close() error
Close tears down all goroutines belonging to the indexer and returns any error that might have occurred internally.
func (*ChainIndexer) SectionHead ¶
func (c *ChainIndexer) SectionHead(section uint64) common.Hash
SectionHead retrieves the last block hash of a processed section from the index database.
type ChainIndexerBackend ¶
type ChainIndexerBackend interface { // Reset initiates the processing of a new chain segment, potentially terminating // any partially completed operations (in case of a reorg). Reset(ctx context.Context, section uint64, prevHead common.Hash) error // Process crunches through the next header in the chain segment. The caller // will ensure a sequential order of headers. Process(ctx context.Context, block *mtypes.Block) error // Commit finalizes the section metadata and stores it into the database. Commit() error }
ChainIndexerBackend defines the methods needed to process chain segments in the background and write the segment results into the database. These can be used to create filter blooms or CHTs.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter can be used to retrieve and filter logs.
func NewBlockFilter ¶
func NewBlockFilter(backend *chain.Chain, ts IBlockHeight, block common.Hash, addresses []common.Address, topics [][]common.Hash) *Filter
NewBlockFilter creates a new filter which directly inspects the contents of a block to figure out whether it is interesting or not.
func NewRangeFilter ¶
func NewRangeFilter(backend *chain.Chain, ts IBlockHeight, bs *BloomBitService, begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter
NewRangeFilter creates a new filter which uses a bloom filter on blocks to figure out whether a particular block is interesting or not.
type FilterQuery ¶
type FilterQuery struct { BlockHash *common.Hash // used by eth_getLogs, return logs only from block with this hash FromBlock *big.Int // beginning of the queried range, nil means genesis block ToBlock *big.Int // end of the range, nil means latest block Addresses []common.Address // restricts matches to events created by specific contracts // The Topic list restricts matches to particular event topics. Each event has a list // of topics. Topics matches a prefix of that list. An empty element slice matches any // topic. Non-empty elements represent an alternative that matches any of the // contained topics. // // Examples: // [] or nil matches any topic list // [A,B] matches topic (A OR B) in first position // [[A]] matches topic A in first position // [[], [B]] matches any topic in first position AND B in second position // [[A], [B]] matches topic A in first position AND B in second position // [[A, B], [C, D]] matches topic (A OR B) in first position AND (C OR D) in second position Topics [][]common.Hash }
FilterQuery contains options for contract log filtering.
func ToFilter ¶
func ToFilter(arg map[string]interface{}) FilterQuery
ToFilter converts map[string]interface{} to FilterQuery struct