More KVGetter (#1697)

This commit is contained in:
Artem Vorotnikov 2021-04-08 19:16:33 +03:00 committed by GitHub
parent c3776f7539
commit eb64d4738d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 13 deletions

View File

@ -484,7 +484,7 @@ func (cs *ControlServerImpl) blockBodies(inreq *proto_sentry.InboundMessage, sen
return nil
}
func getAncestor(db ethdb.Getter, hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) {
func getAncestor(db ethdb.KVGetter, hash common.Hash, number, ancestor uint64, maxNonCanonical *uint64) (common.Hash, uint64) {
if ancestor > number {
return common.Hash{}, 0
}

View File

@ -182,7 +182,7 @@ func ReadHeader(db ethdb.KVGetter, hash common.Hash, number uint64) *types.Heade
return header
}
func ReadCurrentHeader(db ethdb.Getter) *types.Header {
func ReadCurrentHeader(db ethdb.KVGetter) *types.Header {
headHash := ReadHeadHeaderHash(db)
headNumber := ReadHeaderNumber(db, headHash)
if headNumber == nil {
@ -433,7 +433,7 @@ func ReadTd(db ethdb.KVGetter, hash common.Hash, number uint64) (*big.Int, error
return td, nil
}
func ReadTdByHash(db ethdb.Getter, hash common.Hash) (*big.Int, error) {
func ReadTdByHash(db ethdb.KVGetter, hash common.Hash) (*big.Int, error) {
headNumber := ReadHeaderNumber(db, hash)
if headNumber == nil {
return nil, nil
@ -932,7 +932,7 @@ func ReadBlocksByHash(db ethdb.Getter, hash common.Hash, n int) (blocks []*types
return
}
func ReadHeaderByNumber(db ethdb.DatabaseReader, number uint64) *types.Header {
func ReadHeaderByNumber(db ethdb.KVGetter, number uint64) *types.Header {
hash, err := ReadCanonicalHash(db, number)
if err != nil {
log.Error("ReadCanonicalHash failed", "err", err)
@ -945,7 +945,7 @@ func ReadHeaderByNumber(db ethdb.DatabaseReader, number uint64) *types.Header {
return ReadHeader(db, hash, number)
}
func ReadHeaderByHash(db ethdb.DatabaseReader, hash common.Hash) (*types.Header, error) {
func ReadHeaderByHash(db ethdb.KVGetter, hash common.Hash) (*types.Header, error) {
number := ReadHeaderNumber(db, hash)
if number == nil {
return nil, nil

View File

@ -57,7 +57,7 @@ func (s *StageState) Done() {
}
// ExecutionAt gets the current state of the "Execution" stage, which block is currently executed.
func (s *StageState) ExecutionAt(db ethdb.Getter) (uint64, error) {
func (s *StageState) ExecutionAt(db ethdb.KVGetter) (uint64, error) {
execution, err := stages.GetStageProgress(db, stages.Execution)
return execution, err
}

View File

@ -83,7 +83,7 @@ func SaveStageProgress(db ethdb.Putter, stage SyncStage, progress uint64) error
// GetStageUnwind retrieves the invalidation for the given stage
// Invalidation means that that stage needs to rollback to the invalidation
// point and be redone
func GetStageUnwind(db ethdb.Getter, stage SyncStage) (uint64, error) {
func GetStageUnwind(db ethdb.KVGetter, stage SyncStage) (uint64, error) {
v, err := db.GetOne(dbutils.SyncStageUnwind, stage)
if err != nil {
return 0, err

View File

@ -68,7 +68,7 @@ func (s *State) IsAfter(stage1, stage2 stages.SyncStage) bool {
return idx1 > idx2
}
func (s *State) GetLocalHeight(db ethdb.Getter) (uint64, error) {
func (s *State) GetLocalHeight(db ethdb.KVGetter) (uint64, error) {
state, err := s.StageState(stages.Headers, db)
return state.BlockNumber, err
}
@ -130,7 +130,7 @@ func NewState(stagesList []*Stage) *State {
}
}
func (s *State) LoadUnwindInfo(db ethdb.Getter) error {
func (s *State) LoadUnwindInfo(db ethdb.KVGetter) error {
for _, stage := range s.unwindOrder {
if err := s.unwindStack.AddFromDB(db, stage.ID); err != nil {
return err
@ -139,7 +139,7 @@ func (s *State) LoadUnwindInfo(db ethdb.Getter) error {
return nil
}
func (s *State) StageState(stage stages.SyncStage, db ethdb.Getter) (*StageState, error) {
func (s *State) StageState(stage stages.SyncStage, db ethdb.KVGetter) (*StageState, error) {
blockNum, err := stages.GetStageProgress(db, stage)
if err != nil {
return nil, err
@ -213,7 +213,7 @@ func (s *State) Run(db ethdb.GetterPutter, tx ethdb.GetterPutter) error {
return nil
}
func (s *State) runStage(stage *Stage, db ethdb.Getter, tx ethdb.Getter) error {
func (s *State) runStage(stage *Stage, db ethdb.KVGetter, tx ethdb.KVGetter) error {
if hasTx, ok := tx.(ethdb.HasTx); ok && hasTx.Tx() != nil {
db = tx
}

View File

@ -41,7 +41,7 @@ func NewPersistentUnwindStack() *PersistentUnwindStack {
return &PersistentUnwindStack{make([]UnwindState, 0)}
}
func (s *PersistentUnwindStack) AddFromDB(db ethdb.Getter, stageID stages.SyncStage) error {
func (s *PersistentUnwindStack) AddFromDB(db ethdb.KVGetter, stageID stages.SyncStage) error {
u, err := s.LoadFromDB(db, stageID)
if err != nil {
return err
@ -54,7 +54,7 @@ func (s *PersistentUnwindStack) AddFromDB(db ethdb.Getter, stageID stages.SyncSt
return nil
}
func (s *PersistentUnwindStack) LoadFromDB(db ethdb.Getter, stageID stages.SyncStage) (*UnwindState, error) {
func (s *PersistentUnwindStack) LoadFromDB(db ethdb.KVGetter, stageID stages.SyncStage) (*UnwindState, error) {
unwindPoint, err := stages.GetStageUnwind(db, stageID)
if err != nil {
return nil, err