mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
core/rawdb, ethdb, triedb/pathdb: rename to SyncAncient
This commit is contained in:
parent
f750117ad1
commit
7fe474b24c
11 changed files with 21 additions and 21 deletions
|
|
@ -1361,7 +1361,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
||||||
size += writeSize
|
size += writeSize
|
||||||
|
|
||||||
// Sync the ancient store explicitly to ensure all data has been flushed to disk.
|
// Sync the ancient store explicitly to ensure all data has been flushed to disk.
|
||||||
if err := bc.db.Sync(); err != nil {
|
if err := bc.db.SyncAncient(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
// Write hash to number mappings
|
// Write hash to number mappings
|
||||||
|
|
@ -2627,7 +2627,7 @@ func (bc *BlockChain) InsertHeadersBeforeCutoff(headers []*types.Header) (int, e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if err := bc.db.Sync(); err != nil {
|
if err := bc.db.SyncAncient(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
// Write hash to number mappings
|
// Write hash to number mappings
|
||||||
|
|
|
||||||
|
|
@ -205,7 +205,7 @@ func (f *chainFreezer) freeze(db ethdb.KeyValueStore) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Batch of blocks have been frozen, flush them before wiping from key-value store
|
// Batch of blocks have been frozen, flush them before wiping from key-value store
|
||||||
if err := f.Sync(); err != nil {
|
if err := f.SyncAncient(); err != nil {
|
||||||
log.Crit("Failed to flush frozen tables", "err", err)
|
log.Crit("Failed to flush frozen tables", "err", err)
|
||||||
}
|
}
|
||||||
// Wipe out all data from the active database
|
// Wipe out all data from the active database
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,8 @@ func (db *nofreezedb) TruncateTail(items uint64) (uint64, error) {
|
||||||
return 0, errNotSupported
|
return 0, errNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync returns an error as we don't have a backing chain freezer.
|
// SyncAncient returns an error as we don't have a backing chain freezer.
|
||||||
func (db *nofreezedb) Sync() error {
|
func (db *nofreezedb) SyncAncient() error {
|
||||||
return errNotSupported
|
return errNotSupported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -325,8 +325,8 @@ func (f *Freezer) TruncateTail(tail uint64) (uint64, error) {
|
||||||
return old, nil
|
return old, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync flushes all data tables to disk.
|
// SyncAncient flushes all data tables to disk.
|
||||||
func (f *Freezer) Sync() error {
|
func (f *Freezer) SyncAncient() error {
|
||||||
var errs []error
|
var errs []error
|
||||||
for _, table := range f.tables {
|
for _, table := range f.tables {
|
||||||
if err := table.Sync(); err != nil {
|
if err := table.Sync(); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -395,8 +395,8 @@ func (f *MemoryFreezer) TruncateTail(tail uint64) (uint64, error) {
|
||||||
return old, nil
|
return old, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync flushes all data tables to disk.
|
// SyncAncient flushes all data tables to disk.
|
||||||
func (f *MemoryFreezer) Sync() error {
|
func (f *MemoryFreezer) SyncAncient() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,12 +194,12 @@ func (f *resettableFreezer) TruncateTail(tail uint64) (uint64, error) {
|
||||||
return f.freezer.TruncateTail(tail)
|
return f.freezer.TruncateTail(tail)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync flushes all data tables to disk.
|
// SyncAncient flushes all data tables to disk.
|
||||||
func (f *resettableFreezer) Sync() error {
|
func (f *resettableFreezer) SyncAncient() error {
|
||||||
f.lock.RLock()
|
f.lock.RLock()
|
||||||
defer f.lock.RUnlock()
|
defer f.lock.RUnlock()
|
||||||
|
|
||||||
return f.freezer.Sync()
|
return f.freezer.SyncAncient()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AncientDatadir returns the path of the ancient store.
|
// AncientDatadir returns the path of the ancient store.
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ func TestFreezerCloseSync(t *testing.T) {
|
||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := f.Sync(); err == nil {
|
if err := f.SyncAncient(); err == nil {
|
||||||
t.Fatalf("want error, have nil")
|
t.Fatalf("want error, have nil")
|
||||||
} else if have, want := err.Error(), "[closed closed]"; have != want {
|
} else if have, want := err.Error(), "[closed closed]"; have != want {
|
||||||
t.Fatalf("want %v, have %v", have, want)
|
t.Fatalf("want %v, have %v", have, want)
|
||||||
|
|
|
||||||
|
|
@ -107,10 +107,10 @@ func (t *table) TruncateTail(items uint64) (uint64, error) {
|
||||||
return t.db.TruncateTail(items)
|
return t.db.TruncateTail(items)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync is a noop passthrough that just forwards the request to the underlying
|
// SyncAncient is a noop passthrough that just forwards the request to the underlying
|
||||||
// database.
|
// database.
|
||||||
func (t *table) Sync() error {
|
func (t *table) SyncAncient() error {
|
||||||
return t.db.Sync()
|
return t.db.SyncAncient()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AncientDatadir returns the ancient datadir of the underlying database.
|
// AncientDatadir returns the ancient datadir of the underlying database.
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,9 @@ type AncientWriter interface {
|
||||||
// The integer return value is the total size of the written data.
|
// The integer return value is the total size of the written data.
|
||||||
ModifyAncients(func(AncientWriteOp) error) (int64, error)
|
ModifyAncients(func(AncientWriteOp) error) (int64, error)
|
||||||
|
|
||||||
|
// SyncAncient flushes all in-memory ancient store data to disk.
|
||||||
|
SyncAncient() error
|
||||||
|
|
||||||
// TruncateHead discards all but the first n ancient data from the ancient store.
|
// TruncateHead discards all but the first n ancient data from the ancient store.
|
||||||
// After the truncation, the latest item can be accessed it item_n-1(start from 0).
|
// After the truncation, the latest item can be accessed it item_n-1(start from 0).
|
||||||
TruncateHead(n uint64) (uint64, error)
|
TruncateHead(n uint64) (uint64, error)
|
||||||
|
|
@ -138,9 +141,6 @@ type AncientWriter interface {
|
||||||
//
|
//
|
||||||
// Note that data marked as non-prunable will still be retained and remain accessible.
|
// Note that data marked as non-prunable will still be retained and remain accessible.
|
||||||
TruncateTail(n uint64) (uint64, error)
|
TruncateTail(n uint64) (uint64, error)
|
||||||
|
|
||||||
// Sync flushes all in-memory ancient store data to disk.
|
|
||||||
Sync() error
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AncientWriteOp is given to the function argument of ModifyAncients.
|
// AncientWriteOp is given to the function argument of ModifyAncients.
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ func (db *Database) TruncateTail(n uint64) (uint64, error) {
|
||||||
panic("not supported")
|
panic("not supported")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *Database) Sync() error {
|
func (db *Database) SyncAncient() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ func (b *buffer) flush(db ethdb.KeyValueStore, freezer ethdb.AncientWriter, node
|
||||||
// Explicitly sync the state freezer, ensuring that all written
|
// Explicitly sync the state freezer, ensuring that all written
|
||||||
// data is transferred to disk before updating the key-value store.
|
// data is transferred to disk before updating the key-value store.
|
||||||
if freezer != nil {
|
if freezer != nil {
|
||||||
if err := freezer.Sync(); err != nil {
|
if err := freezer.SyncAncient(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue