@@ -34,15 +34,25 @@ type (
34
34
StartHeight () uint64
35
35
}
36
36
37
+ BlockIndexerStateDBWriter interface {
38
+ BlockIndexer
39
+ // StateDBWriter indicates this indexer writes to state DB
40
+ StateDBWriter ()
41
+ }
42
+
37
43
// BlockIndexerChecker defines a checker of block indexer
38
44
BlockIndexerChecker struct {
39
- dao BlockDAO
45
+ dao BlockDAO
46
+ validator block.BlockValidator
40
47
}
41
48
)
42
49
43
50
// NewBlockIndexerChecker creates a new block indexer checker
44
- func NewBlockIndexerChecker (dao BlockDAO ) * BlockIndexerChecker {
45
- return & BlockIndexerChecker {dao : dao }
51
+ func NewBlockIndexerChecker (dao BlockDAO , v block.BlockValidator ) * BlockIndexerChecker {
52
+ return & BlockIndexerChecker {
53
+ dao : dao ,
54
+ validator : v ,
55
+ }
46
56
}
47
57
48
58
// CheckIndexer checks a block indexer against block dao
@@ -115,18 +125,24 @@ func (bic *BlockIndexerChecker) CheckIndexer(ctx context.Context, indexer BlockI
115
125
bcCtx .Tip .Hash = g .Hash ()
116
126
bcCtx .Tip .Timestamp = time .Unix (g .Timestamp , 0 )
117
127
}
128
+ checkCtx := protocol .WithFeatureCtx (protocol .WithBlockCtx (
129
+ protocol .WithBlockchainCtx (ctx , bcCtx ),
130
+ protocol.BlockCtx {
131
+ BlockHeight : i ,
132
+ BlockTimeStamp : blk .Timestamp (),
133
+ Producer : producer ,
134
+ GasLimit : g .BlockGasLimitByHeight (i ),
135
+ BaseFee : blk .BaseFee (),
136
+ ExcessBlobGas : blk .ExcessBlobGas (),
137
+ },
138
+ ))
139
+ if bic .validator != nil {
140
+ if err := bic .validator (checkCtx , blk ); err != nil {
141
+ return err
142
+ }
143
+ }
118
144
for {
119
- if err = indexer .PutBlock (protocol .WithFeatureCtx (protocol .WithBlockCtx (
120
- protocol .WithBlockchainCtx (ctx , bcCtx ),
121
- protocol.BlockCtx {
122
- BlockHeight : i ,
123
- BlockTimeStamp : blk .Timestamp (),
124
- Producer : producer ,
125
- GasLimit : g .BlockGasLimitByHeight (i ),
126
- BaseFee : blk .BaseFee (),
127
- ExcessBlobGas : blk .ExcessBlobGas (),
128
- },
129
- )), blk ); err == nil {
145
+ if err = indexer .PutBlock (checkCtx , blk ); err == nil {
130
146
break
131
147
}
132
148
if i < g .HawaiiBlockHeight && errors .Cause (err ) == block .ErrDeltaStateMismatch {
0 commit comments