plugeth/plugins/wrappers/dbwrapper.go
Austin Roberts 5d4d973cc4 Merge tag 'v1.10.9' into develop
Notes: the AppendAncient plugin hook is broken by this commit.

This adds CaptureEnter() and CaptureExit() as no-ops for interface
compliance, but these capabilities should be added for plugin tracers
soon.
2021-10-18 12:02:35 -05:00

39 lines
2.1 KiB
Go

package wrappers
import (
"fmt"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/openrelayxyz/plugeth-utils/restricted"
)
type dbWrapper struct{
db ethdb.Database
}
func (d *dbWrapper) Has(key []byte) (bool, error) { return d.db.Has(key) }
func (d *dbWrapper) Get(key []byte) ([]byte, error) { return d.db.Get(key) }
func (d *dbWrapper) Put(key []byte, value []byte) error { return d.db.Put(key, value) }
func (d *dbWrapper) Delete(key []byte) error { return d.db.Delete(key) }
func (d *dbWrapper) Stat(property string) (string, error) { return d.db.Stat(property) }
func (d *dbWrapper) Compact(start []byte, limit []byte) error { return d.db.Compact(start, limit) }
func (d *dbWrapper) HasAncient(kind string, number uint64) (bool, error) { return d.db.HasAncient(kind, number) }
func (d *dbWrapper) Ancient(kind string, number uint64) ([]byte, error) { return d.db.Ancient(kind, number) }
func (d *dbWrapper) Ancients() (uint64, error) { return d.db.Ancients() }
func (d *dbWrapper) AncientSize(kind string) (uint64, error) { return d.db.AncientSize(kind) }
func (d *dbWrapper) AppendAncient(number uint64, hash, header, body, receipt, td []byte) error { return fmt.Errorf("AppendAncient is no longer supported in geth 1.10.9 and above. Use ModifyAncients instead.") }
func (d *dbWrapper) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (int64, error) { return d.db.ModifyAncients(fn) }
func (d *dbWrapper) TruncateAncients(n uint64) error { return d.db.TruncateAncients(n) }
func (d *dbWrapper) Sync() error { return d.db.Sync() }
func (d *dbWrapper) Close() error { return d.db.Close() }
func (d *dbWrapper) NewIterator(prefix []byte, start []byte) restricted.Iterator { return &iterWrapper{d.db.NewIterator(prefix, start)} }
type iterWrapper struct {
iter ethdb.Iterator
}
func (it *iterWrapper) Next() bool { return it.iter.Next() }
func (it *iterWrapper) Error() error { return it.iter.Error() }
func (it *iterWrapper) Key() []byte { return it.iter.Key() }
func (it *iterWrapper) Value() []byte { return it.iter.Value() }
func (it *iterWrapper) Release() { it.iter.Release() }