github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/utils/adapters/udb2ethdb/adapter.go (about) 1 package udb2ethdb 2 3 import ( 4 "github.com/unicornultrafoundation/go-helios/u2udb" 5 "github.com/unicornultrafoundation/go-u2u/ethdb" 6 ) 7 8 type Adapter struct { 9 u2udb.Store 10 } 11 12 func (db *Adapter) Stat(property string) (string, error) { 13 //TODO implement me 14 panic("implement me") 15 } 16 17 var _ ethdb.KeyValueStore = (*Adapter)(nil) 18 19 func Wrap(v u2udb.Store) *Adapter { 20 return &Adapter{v} 21 } 22 23 // batch is a write-only memory batch that commits changes to its host 24 // database when Write is called. A batch cannot be used concurrently. 25 type batch struct { 26 u2udb.Batch 27 } 28 29 // Replay replays the batch contents. 30 func (b *batch) Replay(w ethdb.KeyValueWriter) error { 31 return b.Batch.Replay(w) 32 } 33 34 // NewBatch creates a write-only key-value store that buffers changes to its host 35 // database until a final write is called. 36 func (db *Adapter) NewBatch() ethdb.Batch { 37 return &batch{db.Store.NewBatch()} 38 } 39 40 // NewIterator creates a binary-alphabetical iterator over a subset 41 // of database content with a particular key prefix, starting at a particular 42 // initial key (or after, if it does not exist). 43 func (db *Adapter) NewIterator(prefix []byte, start []byte) ethdb.Iterator { 44 return db.Store.NewIterator(prefix, start) 45 }