mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-25 08:36:46 +01:00
Mohammed Sohail
f29e2a9ce7
* move filters to internal folder * rpc block fetcher * add benchmarks: goos: linux goarch: amd64 pkg: github.com/grassrootseconomics/cic-chain-events/pkg/fetch cpu: AMD EPYC Processor Benchmark_RPC Benchmark_RPC/RPC_Block_Fetcher_Benchmark Benchmark_RPC/RPC_Block_Fetcher_Benchmark-4 25 46000646 ns/op 221697 B/op 844 allocs/op Benchmark_GraphQL Benchmark_GraphQL/GraphQL_Block_Fetcher_Benchmark Benchmark_GraphQL/GraphQL_Block_Fetcher_Benchmark-4 56 21219962 ns/op 56686 B/op 94 allocs/op PASS ok github.com/grassrootseconomics/cic-chain-events/pkg/fetch 2.920s
38 lines
965 B
Go
38 lines
965 B
Go
package fetch
|
|
|
|
import "context"
|
|
|
|
// Fetch defines a block fetcher that must return a full JSON response
|
|
type Fetch interface {
|
|
Block(ctx context.Context, block uint64) (fetchResponse FetchResponse, err error)
|
|
}
|
|
|
|
// Transaction reprsents a JSON object of all important mined transaction information
|
|
type Transaction struct {
|
|
Block struct {
|
|
Number uint64 `json:"number"`
|
|
Timestamp string `json:"timestamp"`
|
|
} `json:"block"`
|
|
Hash string `json:"hash"`
|
|
Index uint `json:"index"`
|
|
From struct {
|
|
Address string `json:"address"`
|
|
} `json:"from"`
|
|
To struct {
|
|
Address string `json:"address"`
|
|
} `json:"to"`
|
|
Value string `json:"value"`
|
|
InputData string `json:"inputData"`
|
|
Status uint64 `json:"status"`
|
|
GasUsed uint64 `json:"gasUsed"`
|
|
}
|
|
|
|
// BlockResponse represents a full fetch JSON response
|
|
type FetchResponse struct {
|
|
Data struct {
|
|
Block struct {
|
|
Transactions []Transaction `json:"transactions"`
|
|
} `json:"block"`
|
|
} `json:"data"`
|
|
}
|