Skip to content

Commit e8a5edd

Browse files
committed
Add method to get shrad block range
1 parent ebb57c7 commit e8a5edd

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

SUBQL.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ It's suggested to create a patch or patches of these changes to make it easier t
3131
You can do this by repeating steps 1, 3
3232

3333
e.g `git format-patch --stdout 2d772be398d851a62be53d1b0c162c45bb4876e3..c9760f18c15b8d36af7ef1a9bf5b21056f633b71 > build_fixes.patch`
34-

eth/filters/api_subql.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ package filters
33
import (
44
"context"
55
"encoding/json"
6+
"math"
7+
"math/big"
8+
"sort"
9+
610
"github.com/ethereum/go-ethereum"
711
"github.com/ethereum/go-ethereum/common"
812
"github.com/ethereum/go-ethereum/common/hexutil"
13+
"github.com/ethereum/go-ethereum/core/rawdb"
914
"github.com/ethereum/go-ethereum/core/types"
1015
"github.com/ethereum/go-ethereum/internal/ethapi"
1116
"github.com/ethereum/go-ethereum/log"
1217
"github.com/ethereum/go-ethereum/rpc"
13-
"math"
14-
"math/big"
15-
"sort"
1618
)
1719

1820
type BlockResult struct {
@@ -59,6 +61,11 @@ type SubqlAPI struct {
5961
backend ethapi.Backend
6062
}
6163

64+
type DataInfo struct {
65+
StartBlock int `json:"startBlock"`
66+
EndBlock int `json:"endBlock"`
67+
}
68+
6269
type Capability struct {
6370
AvailableBlocks []struct {
6471
StartHeight int `json:"startHeight"`
@@ -116,6 +123,25 @@ func NewSubqlApi(sys *FilterSystem, backend ethapi.Backend) *SubqlAPI {
116123
return api
117124
}
118125

126+
func (api *SubqlAPI) DataInfo(ctx context.Context) (*DataInfo, error) {
127+
config := rawdb.ReadChainDataConfig(api.backend.ChainDb())
128+
129+
start := 0
130+
if config.DesiredChainDataStart != nil {
131+
start = int(*config.DesiredChainDataStart)
132+
}
133+
134+
end := 0
135+
if config.DesiredChainDataEnd != nil {
136+
end = int(*config.DesiredChainDataEnd)
137+
}
138+
139+
return &DataInfo{
140+
StartBlock: start,
141+
EndBlock: end,
142+
}, nil
143+
}
144+
119145
func (api *SubqlAPI) FilterBlocksCapabilities(ctx context.Context) (*Capability, error) {
120146
res := &Capability{
121147
Filters: map[string][]string{

0 commit comments

Comments
 (0)