Add godoc for Indexer
This commit is contained in:
parent
0ee2149885
commit
09b066b1a3
@ -29,27 +29,39 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// StateDiffIndexer interface required to index statediff data
|
// StateDiffIndexer describes the interface for indexing state data.
|
||||||
type StateDiffIndexer interface {
|
type StateDiffIndexer interface {
|
||||||
DetectGaps(beginBlock uint64, endBlock uint64) ([]*BlockGap, error)
|
// PushBlock indexes block data except for state & storage nodes: header, uncles, transactions &
|
||||||
CurrentBlock() (*models.HeaderModel, error)
|
// receipts. Returns an initiated DB transaction which must be committed or rolled back.
|
||||||
HasBlock(hash common.Hash, number uint64) (bool, error)
|
|
||||||
PushBlock(block *types.Block, receipts types.Receipts, totalDifficulty *big.Int) (Batch, error)
|
PushBlock(block *types.Block, receipts types.Receipts, totalDifficulty *big.Int) (Batch, error)
|
||||||
|
// PushHeader indexes a block header.
|
||||||
PushHeader(batch Batch, header *types.Header, reward, td *big.Int) (string, error)
|
PushHeader(batch Batch, header *types.Header, reward, td *big.Int) (string, error)
|
||||||
|
// PushStateNode indexes a state node and its storage trie.
|
||||||
PushStateNode(tx Batch, stateNode sdtypes.StateLeafNode, headerID string) error
|
PushStateNode(tx Batch, stateNode sdtypes.StateLeafNode, headerID string) error
|
||||||
|
// PushIPLD indexes an IPLD node.
|
||||||
PushIPLD(tx Batch, ipld sdtypes.IPLD) error
|
PushIPLD(tx Batch, ipld sdtypes.IPLD) error
|
||||||
ReportDBMetrics(delay time.Duration, quit <-chan bool)
|
// BeginTx starts a new DB transaction.
|
||||||
|
|
||||||
BeginTx(number *big.Int, ctx context.Context) Batch
|
BeginTx(number *big.Int, ctx context.Context) Batch
|
||||||
|
|
||||||
|
// DetectGaps returns a list of gaps in the block range, if any.
|
||||||
|
DetectGaps(beginBlock uint64, endBlock uint64) ([]*BlockGap, error)
|
||||||
|
// CurrentBlock returns the latest indexed block.
|
||||||
|
CurrentBlock() (*models.HeaderModel, error)
|
||||||
|
// HasBlock returns true if the block is indexed.
|
||||||
|
HasBlock(hash common.Hash, number uint64) (bool, error)
|
||||||
|
|
||||||
|
// Close closes the associated output DB connection or files.
|
||||||
|
Close() error
|
||||||
|
|
||||||
// Methods used by WatchAddress API/functionality
|
// Methods used by WatchAddress API/functionality
|
||||||
|
|
||||||
LoadWatchedAddresses() ([]common.Address, error)
|
LoadWatchedAddresses() ([]common.Address, error)
|
||||||
InsertWatchedAddresses(addresses []sdtypes.WatchAddressArg, currentBlock *big.Int) error
|
InsertWatchedAddresses(addresses []sdtypes.WatchAddressArg, currentBlock *big.Int) error
|
||||||
RemoveWatchedAddresses(addresses []sdtypes.WatchAddressArg) error
|
RemoveWatchedAddresses(addresses []sdtypes.WatchAddressArg) error
|
||||||
SetWatchedAddresses(args []sdtypes.WatchAddressArg, currentBlockNumber *big.Int) error
|
SetWatchedAddresses(args []sdtypes.WatchAddressArg, currentBlockNumber *big.Int) error
|
||||||
ClearWatchedAddresses() error
|
ClearWatchedAddresses() error
|
||||||
|
|
||||||
Close() error
|
ReportDBMetrics(delay time.Duration, quit <-chan bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Batch required for indexing data atomically
|
// Batch required for indexing data atomically
|
||||||
|
@ -26,7 +26,7 @@ func Initialize(ctx core.Context, pl core.PluginLoader, logger core.Logger) {
|
|||||||
gethContext = ctx
|
gethContext = ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeNode(stack core.Node, b core.Backend) {
|
func InitializeNode(_ core.Node, b core.Backend) {
|
||||||
backend := b.(restricted.Backend)
|
backend := b.(restricted.Backend)
|
||||||
|
|
||||||
networkid, err := strconv.ParseUint(gethContext.String(geth_flags.NetworkIdFlag.Name), 10, 64)
|
networkid, err := strconv.ParseUint(gethContext.String(geth_flags.NetworkIdFlag.Name), 10, 64)
|
||||||
|
@ -12,14 +12,15 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cerc-io/eth-iterator-utils/tracker"
|
"github.com/cerc-io/eth-iterator-utils/tracker"
|
||||||
statediff "github.com/cerc-io/plugeth-statediff"
|
|
||||||
"github.com/cerc-io/plugeth-statediff/adapt"
|
|
||||||
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/cerc-io/plugeth-statediff"
|
||||||
|
"github.com/cerc-io/plugeth-statediff/adapt"
|
||||||
|
sdtypes "github.com/cerc-io/plugeth-statediff/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
var subtrieCounts = []uint{1, 8, 32}
|
var subtrieCounts = []uint{1, 8, 32}
|
||||||
|
@ -5,15 +5,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/params"
|
||||||
|
|
||||||
"github.com/cerc-io/plugeth-statediff"
|
"github.com/cerc-io/plugeth-statediff"
|
||||||
"github.com/cerc-io/plugeth-statediff/adapt"
|
"github.com/cerc-io/plugeth-statediff/adapt"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer"
|
"github.com/cerc-io/plugeth-statediff/indexer"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
"github.com/cerc-io/plugeth-statediff/indexer/interfaces"
|
||||||
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
"github.com/cerc-io/plugeth-statediff/indexer/node"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IndexChainParams struct {
|
type IndexChainParams struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user