laconicd-deprecated/state/ethdb.go

67 lines
1.9 KiB
Go
Raw Normal View History

package state
2018-07-04 23:38:20 +00:00
import (
ethdb "github.com/ethereum/go-ethereum/ethdb"
2018-07-04 23:38:20 +00:00
dbm "github.com/tendermint/tendermint/libs/db"
)
// EthereumDB implements Ethereum's ethdb.Database and ethdb.Batch interfaces.
// It will be used to facilitate persistence of codeHash => code mappings.
type EthereumDB struct {
CodeDB dbm.DB
2018-07-04 23:38:20 +00:00
}
// Put implements Ethereum's ethdb.Putter interface. It wraps the database
// write operation supported by both batches and regular databases.
func (edb *EthereumDB) Put(key []byte, value []byte) error {
edb.CodeDB.Set(key, value)
2018-07-04 23:38:20 +00:00
return nil
}
// Get implements Ethereum's ethdb.Database interface. It returns a value for a
// given key.
func (edb *EthereumDB) Get(key []byte) ([]byte, error) {
return edb.CodeDB.Get(key), nil
2018-07-04 23:38:20 +00:00
}
// Has implements Ethereum's ethdb.Database interface. It returns a boolean
// determining if the underlying database has the given key or not.
func (edb *EthereumDB) Has(key []byte) (bool, error) {
return edb.CodeDB.Has(key), nil
2018-07-04 23:38:20 +00:00
}
// Delete implements Ethereum's ethdb.Database interface. It removes a given
// key from the underlying database.
func (edb *EthereumDB) Delete(key []byte) error {
edb.CodeDB.Delete(key)
2018-07-04 23:38:20 +00:00
return nil
}
// Close implements Ethereum's ethdb.Database interface. It closes the
// underlying database.
func (edb *EthereumDB) Close() {
edb.CodeDB.Close()
2018-07-04 23:38:20 +00:00
}
// NewBatch implements Ethereum's ethdb.Database interface. It returns a new
// Batch object used for batch database operations.
func (edb *EthereumDB) NewBatch() ethdb.Batch {
return edb
}
// ValueSize implements Ethereum's ethdb.Database interface. It performs a
// no-op.
func (edb *EthereumDB) ValueSize() int {
return 0
}
// Write implements Ethereum's ethdb.Database interface. It performs a no-op.
func (edb *EthereumDB) Write() error {
return nil
}
// Reset implements Ethereum's ethdb.Database interface. It performs a no-op.
func (edb *EthereumDB) Reset() {
}