mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-24 20:47:16 +00:00
rpcdaemon, stagedsync: make sure we update the current block number after a sync cycle (#1015)
* rpcdaemon, stagedsync: make sure we update the current block number after a sync cycle fixes #1014 * linters
This commit is contained in:
parent
5365b8e402
commit
a1a7f6607a
@ -52,7 +52,7 @@ func NewAPI(db ethdb.KV, dbReader ethdb.Getter, eth ethdb.Backend, gascap uint64
|
||||
}
|
||||
|
||||
func (api *APIImpl) BlockNumber(ctx context.Context) (hexutil.Uint64, error) {
|
||||
execution, _, err := stages.GetStageProgress(api.dbReader, stages.Execution)
|
||||
execution, _, err := stages.GetStageProgress(api.dbReader, stages.Finish)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
@ -158,3 +158,8 @@ During this stage we start the transaction pool or update its state. For instanc
|
||||
On unwinds, we add the transactions from the blocks we unwind, back to the pool.
|
||||
|
||||
This stage doesn't use a network connection.
|
||||
|
||||
### Stage 12: Finish
|
||||
|
||||
This stage sets the current block number that is then used by [RPC calls](../../cmd/rpcdaemon/Readme.md), such as [`eth_blockNumber`](../../README.md).
|
||||
|
||||
|
@ -170,6 +170,26 @@ func (*StagedSync) Prepare(
|
||||
return unwindTxPool(u, s, tx, txPool, quitCh)
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: stages.Finish,
|
||||
Description: "Final: update current block for the RPC API",
|
||||
ExecFunc: func(s *StageState, _ Unwinder) error {
|
||||
var executionAt uint64
|
||||
var err error
|
||||
if executionAt, err = s.ExecutionAt(tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.DoneAndUpdate(tx, executionAt)
|
||||
},
|
||||
UnwindFunc: func(u *UnwindState, s *StageState) error {
|
||||
var executionAt uint64
|
||||
var err error
|
||||
if executionAt, err = s.ExecutionAt(tx); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.DoneAndUpdate(tx, executionAt)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
state := NewState(stages)
|
||||
|
Loading…
Reference in New Issue
Block a user