Skip to content

Commit

Permalink
Migrate ReadFastTrieProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
JukLee0ira committed Jan 15, 2025
1 parent 6b63efd commit 63f1686
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 0 additions & 10 deletions core/database_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ func GetBlockNumber(db rawdb.DatabaseReader, hash common.Hash) uint64 {
return binary.BigEndian.Uint64(data)
}

// ReadFastTrieProgress retrieves the number of tries nodes fast synced to allow
// reportinc correct numbers across restarts.
func ReadFastTrieProgress(db rawdb.DatabaseReader) uint64 {
data, _ := db.Get(trieSyncKey)
if len(data) == 0 {
return 0
}
return new(big.Int).SetBytes(data).Uint64()
}

func blockBodyKey(hash common.Hash, number uint64) []byte {
return append(append(bodyPrefix, encodeBlockNumber(number)...), hash.Bytes()...)
}
Expand Down
10 changes: 10 additions & 0 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ func WriteHeadFastBlockHash(db ethdb.KeyValueWriter, hash common.Hash) {
}
}

// ReadFastTrieProgress retrieves the number of tries nodes fast synced to allow
// reportinc correct numbers across restarts.
func ReadFastTrieProgress(db DatabaseReader) uint64 {
data, _ := db.Get(trieSyncKey)
if len(data) == 0 {
return 0
}
return new(big.Int).SetBytes(data).Uint64()
}

// ReadHeaderRLP retrieves a block header in its raw RLP database encoding.
func ReadHeaderRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue {
// First try to look up the data in ancient database. Extra hash
Expand Down
4 changes: 2 additions & 2 deletions eth/downloader/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

"github.com/XinFinOrg/XDPoSChain"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
"github.com/XinFinOrg/XDPoSChain/core/types"
"github.com/XinFinOrg/XDPoSChain/ethdb"
"github.com/XinFinOrg/XDPoSChain/event"
Expand Down Expand Up @@ -230,7 +230,7 @@ func New(mode SyncMode, stateDb ethdb.Database, mux *event.TypeMux, chain BlockC
stateCh: make(chan dataPack),
stateSyncStart: make(chan *stateSync),
syncStatsState: stateSyncStats{
processed: core.ReadFastTrieProgress(stateDb),
processed: rawdb.ReadFastTrieProgress(stateDb),
},
trackStateReq: make(chan *stateReq),
}
Expand Down

0 comments on commit 63f1686

Please sign in to comment.