2023-01-05 12:45:09 +01:00
|
|
|
package fetch
|
|
|
|
|
2023-01-11 09:13:59 +01:00
|
|
|
import "context"
|
|
|
|
|
2023-01-05 12:45:09 +01:00
|
|
|
// Fetch defines a block fetcher that must return a full JSON response
|
|
|
|
type Fetch interface {
|
2023-01-11 09:13:59 +01:00
|
|
|
Block(ctx context.Context, block uint64) (fetchResponse FetchResponse, err error)
|
2023-01-05 12:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Transaction reprsents a JSON object of all important mined transaction information
|
|
|
|
type Transaction struct {
|
|
|
|
Block struct {
|
2023-01-17 10:17:32 +01:00
|
|
|
Number uint64 `json:"number"`
|
2023-01-05 12:45:09 +01:00
|
|
|
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"`
|
2023-01-17 10:17:32 +01:00
|
|
|
Status uint64 `json:"status"`
|
|
|
|
GasUsed uint64 `json:"gasUsed"`
|
2023-01-05 12:45:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// BlockResponse represents a full fetch JSON response
|
|
|
|
type FetchResponse struct {
|
|
|
|
Data struct {
|
|
|
|
Block struct {
|
|
|
|
Transactions []Transaction `json:"transactions"`
|
|
|
|
} `json:"block"`
|
|
|
|
} `json:"data"`
|
|
|
|
}
|