Updates to satisfy geth v1.10.17 database interfaces

This commit is contained in:
Prathamesh Musale 2022-04-20 16:08:50 +05:30
parent e0c235c2ff
commit c9e57bf7af
2 changed files with 70 additions and 18 deletions

View File

@ -160,6 +160,16 @@ func (d *Database) NewBatch() ethdb.Batch {
return b return b
} }
// NewBatchWithSize satisfies the ethdb.Batcher interface.
// NewBatchWithSize creates a write-only database batch with pre-allocated buffer.
func (d *Database) NewBatchWithSize(size int) ethdb.Batch {
b, err := NewBatch(d.blockService, size)
if err != nil {
panic(err)
}
return b
}
// NewIterator satisfies the ethdb.Iteratee interface // NewIterator satisfies the ethdb.Iteratee interface
// it creates a binary-alphabetical iterator over a subset // it creates a binary-alphabetical iterator over a subset
// of database content with a particular key prefix, starting at a particular // of database content with a particular key prefix, starting at a particular
@ -195,18 +205,18 @@ func (d *Database) Ancients() (uint64, error) {
return 0, errNotSupported return 0, errNotSupported
} }
// Tail satisfies the ethdb.AncientReader interface.
// Tail returns the number of first stored item in the freezer.
func (d *Database) Tail() (uint64, error) {
return 0, errNotSupported
}
// AncientSize satisfies the ethdb.AncientReader interface // AncientSize satisfies the ethdb.AncientReader interface
// AncientSize returns the ancient size of the specified category // AncientSize returns the ancient size of the specified category
func (d *Database) AncientSize(kind string) (uint64, error) { func (d *Database) AncientSize(kind string) (uint64, error) {
return 0, errNotSupported return 0, errNotSupported
} }
// AppendAncient satisfies the ethdb.AncientWriter interface
// AppendAncient injects all binary blobs belong to block at the end of the append-only immutable table files
func (d *Database) AppendAncient(number uint64, hash, header, body, receipt, td []byte) error {
return errNotSupported
}
// AncientRange retrieves all the items in a range, starting from the index 'start'. // AncientRange retrieves all the items in a range, starting from the index 'start'.
// It will return // It will return
// - at most 'count' items, // - at most 'count' items,
@ -221,9 +231,15 @@ func (d *Database) ReadAncients(fn func(ethdb.AncientReader) error) (err error)
return errNotSupported return errNotSupported
} }
// TruncateAncients satisfies the ethdb.AncientWriter interface // TruncateHead satisfies the ethdb.AncientWriter interface.
// TruncateAncients 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.
func (d *Database) TruncateAncients(n uint64) error { func (d *Database) TruncateHead(n uint64) error {
return errNotSupported
}
// TruncateTail satisfies the ethdb.AncientWriter interface.
// TruncateTail discards the first n ancient data from the ancient store.
func (d *Database) TruncateTail(n uint64) error {
return errNotSupported return errNotSupported
} }
@ -232,3 +248,15 @@ func (d *Database) TruncateAncients(n uint64) error {
func (d *Database) Sync() error { func (d *Database) Sync() error {
return errNotSupported return errNotSupported
} }
// MigrateTable satisfies the ethdb.AncientWriter interface.
// MigrateTable processes and migrates entries of a given table to a new format.
func (d *Database) MigrateTable(string, func([]byte) ([]byte, error)) error {
return errNotSupported
}
// NewSnapshot satisfies the ethdb.Snapshotter interface.
// NewSnapshot creates a database snapshot based on the current state.
func (d *Database) NewSnapshot() (ethdb.Snapshot, error) {
return nil, errNotSupported
}

View File

@ -248,6 +248,12 @@ func (d *Database) NewBatch() ethdb.Batch {
return NewBatch(d.db, nil) return NewBatch(d.db, nil)
} }
// NewBatchWithSize satisfies the ethdb.Batcher interface.
// NewBatchWithSize creates a write-only database batch with pre-allocated buffer.
func (d *Database) NewBatchWithSize(size int) ethdb.Batch {
return NewBatch(d.db, nil)
}
// NewIterator satisfies the ethdb.Iteratee interface // NewIterator satisfies the ethdb.Iteratee interface
// it creates a binary-alphabetical iterator over a subset // it creates a binary-alphabetical iterator over a subset
// of database content with a particular key prefix, starting at a particular // of database content with a particular key prefix, starting at a particular
@ -283,18 +289,18 @@ func (d *Database) Ancients() (uint64, error) {
return 0, errNotSupported return 0, errNotSupported
} }
// Tail satisfies the ethdb.AncientReader interface.
// Tail returns the number of first stored item in the freezer.
func (d *Database) Tail() (uint64, error) {
return 0, errNotSupported
}
// AncientSize satisfies the ethdb.AncientReader interface // AncientSize satisfies the ethdb.AncientReader interface
// AncientSize returns the ancient size of the specified category // AncientSize returns the ancient size of the specified category
func (d *Database) AncientSize(kind string) (uint64, error) { func (d *Database) AncientSize(kind string) (uint64, error) {
return 0, errNotSupported return 0, errNotSupported
} }
// AppendAncient satisfies the ethdb.AncientWriter interface
// AppendAncient injects all binary blobs belong to block at the end of the append-only immutable table files
func (d *Database) AppendAncient(number uint64, hash, header, body, receipt, td []byte) error {
return errNotSupported
}
// AncientRange retrieves all the items in a range, starting from the index 'start'. // AncientRange retrieves all the items in a range, starting from the index 'start'.
// It will return // It will return
// - at most 'count' items, // - at most 'count' items,
@ -309,9 +315,15 @@ func (d *Database) ReadAncients(fn func(ethdb.AncientReader) error) (err error)
return errNotSupported return errNotSupported
} }
// TruncateAncients satisfies the ethdb.AncientWriter interface // TruncateHead satisfies the ethdb.AncientWriter interface.
// TruncateAncients 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.
func (d *Database) TruncateAncients(n uint64) error { func (d *Database) TruncateHead(n uint64) error {
return errNotSupported
}
// TruncateTail satisfies the ethdb.AncientWriter interface.
// TruncateTail discards the first n ancient data from the ancient store.
func (d *Database) TruncateTail(n uint64) error {
return errNotSupported return errNotSupported
} }
@ -320,3 +332,15 @@ func (d *Database) TruncateAncients(n uint64) error {
func (d *Database) Sync() error { func (d *Database) Sync() error {
return errNotSupported return errNotSupported
} }
// MigrateTable satisfies the ethdb.AncientWriter interface.
// MigrateTable processes and migrates entries of a given table to a new format.
func (d *Database) MigrateTable(string, func([]byte) ([]byte, error)) error {
return errNotSupported
}
// NewSnapshot satisfies the ethdb.Snapshotter interface.
// NewSnapshot creates a database snapshot based on the current state.
func (d *Database) NewSnapshot() (ethdb.Snapshot, error) {
return nil, errNotSupported
}