Documentation
¶
Index ¶
- Constants
- func CalcEthBlockReward(header *types.Header, uncles []*types.Header, txs types.Transactions, ...) *big.Int
- func CalcUncleMinerReward(blockNumber, uncleBlockNumber uint64) *big.Int
- func ChainConfig(chainID uint64) (*params.ChainConfig, error)
- func ReceiptModelsContainsCID(rcts []ReceiptModel, cid string) bool
- func ResolveFromNodeType(nodeType statediff.NodeType) int
- func TearDownDB(db *postgres.DB)
- func TxModelsContainsCID(txs []TxModel, cid string) bool
- type BatchClient
- type CIDIndexer
- type CIDPayload
- type Cleaner
- type ConvertedPayload
- type Converter
- type DBCleaner
- type DBGap
- type Fetcher
- type GapRetriever
- type HeaderModel
- type IPLDPublisher
- type Indexer
- type PayloadConverter
- type PayloadFetcher
- type PayloadStreamer
- type Publisher
- type ReceiptModel
- type Retriever
- type StateAccountModel
- type StateDiffTransformer
- type StateNodeModel
- type StorageNodeModel
- type StorageNodeWithStateKeyModel
- type StreamClient
- type Streamer
- type Transformer
- type TrieNode
- type TxModel
- type UncleModel
Constants ¶
const (
PayloadChanBufferSize = 20000 // the max eth sub buffer size
)
Variables ¶
This section is empty.
Functions ¶
func CalcEthBlockReward ¶
func CalcUncleMinerReward ¶
func ChainConfig ¶
func ChainConfig(chainID uint64) (*params.ChainConfig, error)
ChainConfig returns the appropriate ethereum chain config for the provided chain id
func ReceiptModelsContainsCID ¶
func ReceiptModelsContainsCID(rcts []ReceiptModel, cid string) bool
ListContainsBytes used to check if a list of byte arrays contains a particular byte array
func ResolveFromNodeType ¶
func TearDownDB ¶
TearDownDB is used to tear down the watcher dbs after tests
func TxModelsContainsCID ¶
TxModelsContainsCID used to check if a list of TxModels contains a specific cid string
Types ¶
type BatchClient ¶
BatchClient is an interface to a batch-fetching geth rpc client; created to allow mock insertion
type CIDIndexer ¶
type CIDIndexer struct {
// contains filtered or unexported fields
}
Indexer satisfies the Indexer interface for ethereum
func NewCIDIndexer ¶
func NewCIDIndexer(db *postgres.DB) *CIDIndexer
NewCIDIndexer creates a new pointer to a Indexer which satisfies the CIDIndexer interface
func (*CIDIndexer) Index ¶
func (in *CIDIndexer) Index(cids CIDPayload) error
Index indexes a cidPayload in Postgres
type CIDPayload ¶
type CIDPayload struct { HeaderCID HeaderModel UncleCIDs []UncleModel TransactionCIDs []TxModel ReceiptCIDs map[common.Hash]ReceiptModel StateNodeCIDs []StateNodeModel StateAccounts map[string]StateAccountModel StorageNodeCIDs map[string][]StorageNodeModel }
CIDPayload is a struct to hold all the CIDs and their associated meta data for indexing in Postgres Returned by IPLDPublisher Passed to CIDIndexer
type Cleaner ¶
type Cleaner interface { ResetValidation(rngs [][2]uint64) error Clean(rngs [][2]uint64, t shared.DataType) error }
Cleaner interface to allow substitution of mocks in tests
type ConvertedPayload ¶
type ConvertedPayload struct { TotalDifficulty *big.Int Block *types.Block TxMetaData []TxModel Receipts types.Receipts ReceiptMetaData []ReceiptModel StateNodes []TrieNode StorageNodes map[string][]TrieNode }
ConvertedPayload is a custom type which packages raw ETH data for publishing to IPFS and filtering to subscribers Returned by PayloadConverter Passed to IPLDPublisher and ResponseFilterer
type Converter ¶
type Converter interface {
Convert(payload statediff.Payload) (*ConvertedPayload, error)
}
Converter interface to allow substitution of mocks for testing
type DBCleaner ¶
type DBCleaner struct {
// contains filtered or unexported fields
}
DBCleaner satisfies the Cleaner interface fo ethereum
func NewDBCleaner ¶
NewDBCleaner returns a new DBCleaner struct
func (*DBCleaner) Clean ¶
Clean removes the specified data from the db within the provided block range
func (*DBCleaner) ResetValidation ¶
ResetValidation resets the validation level to 0 to enable revalidation
type DBGap ¶
DBGap type for querying for gaps in db
func MissingHeightsToGaps ¶
MissingHeightsToGaps returns a slice of gaps from a slice of missing block heights
type GapRetriever ¶
type GapRetriever struct {
// contains filtered or unexported fields
}
GapRetriever type for Ethereum
func NewGapRetriever ¶
func NewGapRetriever(db *postgres.DB) *GapRetriever
NewGapRetriever returns a pointer to a new GapRetriever
func (*GapRetriever) RetrieveFirstBlockNumber ¶
func (ecr *GapRetriever) RetrieveFirstBlockNumber() (int64, error)
RetrieveFirstBlockNumber is used to retrieve the first block number in the db
func (*GapRetriever) RetrieveGapsInData ¶
func (ecr *GapRetriever) RetrieveGapsInData(validationLevel int) ([]DBGap, error)
RetrieveGapsInData is used to find the the block numbers at which we are missing data in the db it finds the union of heights where no data exists and where the times_validated is lower than the validation level
func (*GapRetriever) RetrieveLastBlockNumber ¶
func (ecr *GapRetriever) RetrieveLastBlockNumber() (int64, error)
RetrieveLastBlockNumber is used to retrieve the latest block number in the db
type HeaderModel ¶
type HeaderModel struct { ID int64 `db:"id"` BlockNumber string `db:"block_number"` BlockHash string `db:"block_hash"` ParentHash string `db:"parent_hash"` CID string `db:"cid"` MhKey string `db:"mh_key"` TotalDifficulty string `db:"td"` NodeID int64 `db:"node_id"` Reward string `db:"reward"` StateRoot string `db:"state_root"` UncleRoot string `db:"uncle_root"` TxRoot string `db:"tx_root"` RctRoot string `db:"receipt_root"` Bloom []byte `db:"bloom"` Timestamp uint64 `db:"timestamp"` TimesValidated int64 `db:"times_validated"` }
HeaderModel is the db model for eth.header_cids
type IPLDPublisher ¶
type IPLDPublisher struct {
// contains filtered or unexported fields
}
IPLDPublisher satisfies the IPLDPublisher interface for ethereum It interfaces directly with the public.blocks table of PG-IPFS rather than going through an ipfs intermediary It publishes and indexes IPLDs together in a single sqlx.Tx
func NewIPLDPublisher ¶
func NewIPLDPublisher(db *postgres.DB) *IPLDPublisher
NewIPLDPublisher creates a pointer to a new IPLDPublisher which satisfies the IPLDPublisher interface
func (*IPLDPublisher) Publish ¶
func (pub *IPLDPublisher) Publish(payload ConvertedPayload) error
Publish publishes an IPLDPayload to IPFS and returns the corresponding CIDPayload
type Indexer ¶
type Indexer interface {
Index(cids CIDPayload) error
}
Indexer interface to allow substituting mocks in tests
type PayloadConverter ¶
type PayloadConverter struct {
// contains filtered or unexported fields
}
PayloadConverter satisfies the PayloadConverter interface for ethereum
func NewPayloadConverter ¶
func NewPayloadConverter(chainConfig *params.ChainConfig) *PayloadConverter
NewPayloadConverter creates a pointer to a new PayloadConverter which satisfies the PayloadConverter interface
func (*PayloadConverter) Convert ¶
func (pc *PayloadConverter) Convert(payload statediff.Payload) (*ConvertedPayload, error)
Convert method is used to convert a eth statediff.Payload to an IPLDPayload Satisfies the shared.PayloadConverter interface
type PayloadFetcher ¶
type PayloadFetcher struct {
// contains filtered or unexported fields
}
PayloadFetcher satisfies the PayloadFetcher interface for ethereum
func NewPayloadFetcher ¶
func NewPayloadFetcher(bc BatchClient, timeout time.Duration) *PayloadFetcher
NewPayloadFetcher returns a PayloadFetcher
type PayloadStreamer ¶
type PayloadStreamer struct { Client StreamClient // contains filtered or unexported fields }
PayloadStreamer satisfies the PayloadStreamer interface for ethereum
func NewPayloadStreamer ¶
func NewPayloadStreamer(client StreamClient) *PayloadStreamer
NewPayloadStreamer creates a pointer to a new PayloadStreamer which satisfies the PayloadStreamer interface for ethereum
func (*PayloadStreamer) Stream ¶
func (ps *PayloadStreamer) Stream(payloadChan chan statediff.Payload) (*rpc.ClientSubscription, error)
Stream is the main loop for subscribing to data from the Geth state diff process Satisfies the shared.PayloadStreamer interface
type Publisher ¶
type Publisher interface {
Publish(payload ConvertedPayload) error
}
Publisher interface for substituting mocks in tests
type ReceiptModel ¶
type ReceiptModel struct { ID int64 `db:"id"` TxID int64 `db:"tx_id"` CID string `db:"cid"` MhKey string `db:"mh_key"` Contract string `db:"contract"` ContractHash string `db:"contract_hash"` LogContracts pq.StringArray `db:"log_contracts"` Topic0s pq.StringArray `db:"topic0s"` Topic1s pq.StringArray `db:"topic1s"` Topic2s pq.StringArray `db:"topic2s"` Topic3s pq.StringArray `db:"topic3s"` }
ReceiptModel is the db model for eth.receipt_cids
type Retriever ¶
type Retriever interface { RetrieveFirstBlockNumber() (int64, error) RetrieveLastBlockNumber() (int64, error) RetrieveGapsInData(validationLevel int) ([]DBGap, error) }
Retriever interface for substituting mocks in tests
type StateAccountModel ¶
type StateAccountModel struct { ID int64 `db:"id"` StateID int64 `db:"state_id"` Balance string `db:"balance"` Nonce uint64 `db:"nonce"` CodeHash []byte `db:"code_hash"` StorageRoot string `db:"storage_root"` }
StateAccountModel is a db model for an eth state account (decoded value of state leaf node)
type StateDiffTransformer ¶
type StateDiffTransformer struct {
// contains filtered or unexported fields
}
StateDiffTransformer satisfies the Transformer interface for ethereum statediff objects
func NewStateDiffTransformer ¶
func NewStateDiffTransformer(chainConfig *params.ChainConfig, db *postgres.DB) *StateDiffTransformer
NewStateDiffTransformer creates a pointer to a new PayloadConverter which satisfies the PayloadConverter interface
type StateNodeModel ¶
type StateNodeModel struct { ID int64 `db:"id"` HeaderID int64 `db:"header_id"` Path []byte `db:"state_path"` StateKey string `db:"state_leaf_key"` NodeType int `db:"node_type"` CID string `db:"cid"` MhKey string `db:"mh_key"` Diff bool `db:"diff"` }
StateNodeModel is the db model for eth.state_cids
type StorageNodeModel ¶
type StorageNodeModel struct { ID int64 `db:"id"` StateID int64 `db:"state_id"` Path []byte `db:"storage_path"` StorageKey string `db:"storage_leaf_key"` NodeType int `db:"node_type"` CID string `db:"cid"` MhKey string `db:"mh_key"` Diff bool `db:"diff"` }
StorageNodeModel is the db model for eth.storage_cids
type StorageNodeWithStateKeyModel ¶
type StorageNodeWithStateKeyModel struct { ID int64 `db:"id"` StateID int64 `db:"state_id"` Path []byte `db:"storage_path"` StateKey string `db:"state_leaf_key"` StorageKey string `db:"storage_leaf_key"` NodeType int `db:"node_type"` CID string `db:"cid"` MhKey string `db:"mh_key"` Diff bool `db:"diff"` }
StorageNodeWithStateKeyModel is a db model for eth.storage_cids + eth.state_cids.state_key
type StreamClient ¶
type StreamClient interface {
Subscribe(ctx context.Context, namespace string, payloadChan interface{}, args ...interface{}) (*rpc.ClientSubscription, error)
}
StreamClient is an interface for subscribing and streaming from geth
type Streamer ¶
type Streamer interface {
Stream(payloadChan chan statediff.Payload) (*rpc.ClientSubscription, error)
}
Streamer interface for substituting mocks in tests
type Transformer ¶
Transformer interface to allow substitution of mocks for testing
type TxModel ¶
type TxModel struct { ID int64 `db:"id"` HeaderID int64 `db:"header_id"` Index int64 `db:"index"` TxHash string `db:"tx_hash"` CID string `db:"cid"` MhKey string `db:"mh_key"` Dst string `db:"dst"` Src string `db:"src"` Data []byte `db:"tx_data"` Deployment bool `db:"deployment"` }
TxModel is the db model for eth.transaction_cids