mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
ethdb: add log
This commit is contained in:
parent
b474628f03
commit
86e3f1fc3a
2 changed files with 19 additions and 5 deletions
|
|
@ -23,11 +23,11 @@ package leveldb
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/ethdb"
|
"github.com/ethereum/go-ethereum/ethdb"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
|
|
@ -222,11 +222,18 @@ func (db *Database) DeleteRange(start, end []byte) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
count int
|
count int
|
||||||
|
ignored int
|
||||||
buff = crypto.NewKeccakState()
|
buff = crypto.NewKeccakState()
|
||||||
)
|
)
|
||||||
|
defer func() {
|
||||||
|
if ignored > 0 {
|
||||||
|
log.Info("Skipped entries from deletion", "number", ignored)
|
||||||
|
}
|
||||||
|
}()
|
||||||
for it.Next() && bytes.Compare(end, it.Key()) > 0 {
|
for it.Next() && bytes.Compare(end, it.Key()) > 0 {
|
||||||
// Prevent deletion for trie nodes in hash mode
|
// Prevent deletion for trie nodes in hash mode
|
||||||
if h := crypto.HashData(buff, it.Value()); h == common.BytesToHash(it.Key()) {
|
if h := crypto.HashData(buff, it.Value()); h == common.BytesToHash(it.Key()) {
|
||||||
|
ignored++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
|
|
|
||||||
|
|
@ -360,11 +360,18 @@ func (d *Database) DeleteRange(start, end []byte) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
count int
|
count int
|
||||||
|
ignored int
|
||||||
buff = crypto.NewKeccakState()
|
buff = crypto.NewKeccakState()
|
||||||
)
|
)
|
||||||
|
defer func() {
|
||||||
|
if ignored > 0 {
|
||||||
|
log.Info("Skipped entries from deletion", "number", ignored)
|
||||||
|
}
|
||||||
|
}()
|
||||||
for it.Next() && bytes.Compare(end, it.Key()) > 0 {
|
for it.Next() && bytes.Compare(end, it.Key()) > 0 {
|
||||||
// Prevent deletion for trie nodes in hash mode
|
// Prevent deletion for trie nodes in hash mode
|
||||||
if h := crypto.HashData(buff, it.Value()); h == common.BytesToHash(it.Key()) {
|
if h := crypto.HashData(buff, it.Value()); h == common.BytesToHash(it.Key()) {
|
||||||
|
ignored++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue