aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-09-14 15:35:57 +0800
committerFelix Lange <fjl@twurst.com>2015-09-15 05:36:30 +0800
commit8c4dab77ba48dc68073fe1df79e7000043c0f966 (patch)
tree09ebb0fdb1b72e49ea2cfb9ebdc55a73a174302a /core
parent55ed8d108d72d12543ecdc6d8c9d9978392dabf0 (diff)
downloaddexon-8c4dab77ba48dc68073fe1df79e7000043c0f966.tar
dexon-8c4dab77ba48dc68073fe1df79e7000043c0f966.tar.gz
dexon-8c4dab77ba48dc68073fe1df79e7000043c0f966.tar.bz2
dexon-8c4dab77ba48dc68073fe1df79e7000043c0f966.tar.lz
dexon-8c4dab77ba48dc68073fe1df79e7000043c0f966.tar.xz
dexon-8c4dab77ba48dc68073fe1df79e7000043c0f966.tar.zst
dexon-8c4dab77ba48dc68073fe1df79e7000043c0f966.zip
all: move common.Database to package ethdb
Diffstat (limited to 'core')
-rw-r--r--core/bench_test.go2
-rw-r--r--core/block_processor.go5
-rw-r--r--core/chain_makers.go7
-rw-r--r--core/chain_manager.go5
-rw-r--r--core/chain_manager_test.go4
-rw-r--r--core/chain_util.go45
-rw-r--r--core/genesis.go9
-rw-r--r--core/helper_test.go6
-rw-r--r--core/manager.go6
-rw-r--r--core/state/state_object.go7
-rw-r--r--core/state/statedb.go5
-rw-r--r--core/transaction_util.go10
12 files changed, 59 insertions, 52 deletions
diff --git a/core/bench_test.go b/core/bench_test.go
index baae8a7a5..d05b7d30b 100644
--- a/core/bench_test.go
+++ b/core/bench_test.go
@@ -144,7 +144,7 @@ func genUncles(i int, gen *BlockGen) {
func benchInsertChain(b *testing.B, disk bool, gen func(int, *BlockGen)) {
// Create the database in memory or in a temporary directory.
- var db common.Database
+ var db ethdb.Database
if !disk {
db, _ = ethdb.NewMemDatabase()
} else {
diff --git a/core/block_processor.go b/core/block_processor.go
index 1238fda7b..1d3bc6656 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
@@ -41,7 +42,7 @@ const (
)
type BlockProcessor struct {
- chainDb common.Database
+ chainDb ethdb.Database
// Mutex for locking the block processor. Blocks can only be handled one at a time
mutex sync.Mutex
// Canonical block chain
@@ -68,7 +69,7 @@ type GasPool interface {
SubGas(gas, price *big.Int) error
}
-func NewBlockProcessor(db common.Database, pow pow.PoW, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
+func NewBlockProcessor(db ethdb.Database, pow pow.PoW, chainManager *ChainManager, eventMux *event.TypeMux) *BlockProcessor {
sm := &BlockProcessor{
chainDb: db,
mem: make(map[string]*big.Int),
diff --git a/core/chain_makers.go b/core/chain_makers.go
index f89218f82..d3b7c42b6 100644
--- a/core/chain_makers.go
+++ b/core/chain_makers.go
@@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/pow"
)
@@ -142,7 +143,7 @@ func (b *BlockGen) PrevBlock(index int) *types.Block {
// Blocks created by GenerateChain do not contain valid proof of work
// values. Inserting them into ChainManager requires use of FakePow or
// a similar non-validating proof of work implementation.
-func GenerateChain(parent *types.Block, db common.Database, n int, gen func(int, *BlockGen)) []*types.Block {
+func GenerateChain(parent *types.Block, db ethdb.Database, n int, gen func(int, *BlockGen)) []*types.Block {
statedb := state.New(parent.Root(), db)
blocks := make(types.Blocks, n)
genblock := func(i int, h *types.Header) *types.Block {
@@ -185,7 +186,7 @@ func makeHeader(parent *types.Block, state *state.StateDB) *types.Header {
// newCanonical creates a new deterministic canonical chain by running
// InsertChain on the result of makeChain.
-func newCanonical(n int, db common.Database) (*BlockProcessor, error) {
+func newCanonical(n int, db ethdb.Database) (*BlockProcessor, error) {
evmux := &event.TypeMux{}
WriteTestNetGenesisBlock(db, 0)
@@ -201,7 +202,7 @@ func newCanonical(n int, db common.Database) (*BlockProcessor, error) {
return bman, err
}
-func makeChain(parent *types.Block, n int, db common.Database, seed int) []*types.Block {
+func makeChain(parent *types.Block, n int, db ethdb.Database, seed int) []*types.Block {
return GenerateChain(parent, db, n, func(i int, b *BlockGen) {
b.SetCoinbase(common.Address{0: byte(seed), 19: byte(i)})
})
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 407945f8e..1218b1a6e 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -30,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
@@ -60,7 +61,7 @@ const (
type ChainManager struct {
//eth EthManager
- chainDb common.Database
+ chainDb ethdb.Database
processor types.BlockProcessor
eventMux *event.TypeMux
genesisBlock *types.Block
@@ -90,7 +91,7 @@ type ChainManager struct {
pow pow.PoW
}
-func NewChainManager(chainDb common.Database, pow pow.PoW, mux *event.TypeMux) (*ChainManager, error) {
+func NewChainManager(chainDb ethdb.Database, pow pow.PoW, mux *event.TypeMux) (*ChainManager, error) {
headerCache, _ := lru.New(headerCacheLimit)
bodyCache, _ := lru.New(bodyCacheLimit)
bodyRLPCache, _ := lru.New(bodyCacheLimit)
diff --git a/core/chain_manager_test.go b/core/chain_manager_test.go
index a20480de8..67ca41f00 100644
--- a/core/chain_manager_test.go
+++ b/core/chain_manager_test.go
@@ -46,7 +46,7 @@ func thePow() pow.PoW {
return pow
}
-func theChainManager(db common.Database, t *testing.T) *ChainManager {
+func theChainManager(db ethdb.Database, t *testing.T) *ChainManager {
var eventMux event.TypeMux
WriteTestNetGenesisBlock(db, 0)
chainMan, err := NewChainManager(db, thePow(), &eventMux)
@@ -380,7 +380,7 @@ func makeChainWithDiff(genesis *types.Block, d []int, seed byte) []*types.Block
return chain
}
-func chm(genesis *types.Block, db common.Database) *ChainManager {
+func chm(genesis *types.Block, db ethdb.Database) *ChainManager {
var eventMux event.TypeMux
bc := &ChainManager{chainDb: db, genesisBlock: genesis, eventMux: &eventMux, pow: FakePow{}}
bc.headerCache, _ = lru.New(100)
diff --git a/core/chain_util.go b/core/chain_util.go
index 0e3fa31f9..33d94cebd 100644
--- a/core/chain_util.go
+++ b/core/chain_util.go
@@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
@@ -111,7 +112,7 @@ func CalcGasLimit(parent *types.Block) *big.Int {
}
// GetCanonicalHash retrieves a hash assigned to a canonical block number.
-func GetCanonicalHash(db common.Database, number uint64) common.Hash {
+func GetCanonicalHash(db ethdb.Database, number uint64) common.Hash {
data, _ := db.Get(append(blockNumPrefix, big.NewInt(int64(number)).Bytes()...))
if len(data) == 0 {
return common.Hash{}
@@ -124,7 +125,7 @@ func GetCanonicalHash(db common.Database, number uint64) common.Hash {
// last block hash is only updated upon a full block import, the last header
// hash is updated already at header import, allowing head tracking for the
// fast synchronization mechanism.
-func GetHeadHeaderHash(db common.Database) common.Hash {
+func GetHeadHeaderHash(db ethdb.Database) common.Hash {
data, _ := db.Get(headHeaderKey)
if len(data) == 0 {
return common.Hash{}
@@ -133,7 +134,7 @@ func GetHeadHeaderHash(db common.Database) common.Hash {
}
// GetHeadBlockHash retrieves the hash of the current canonical head block.
-func GetHeadBlockHash(db common.Database) common.Hash {
+func GetHeadBlockHash(db ethdb.Database) common.Hash {
data, _ := db.Get(headBlockKey)
if len(data) == 0 {
return common.Hash{}
@@ -143,14 +144,14 @@ func GetHeadBlockHash(db common.Database) common.Hash {
// GetHeaderRLP retrieves a block header in its raw RLP database encoding, or nil
// if the header's not found.
-func GetHeaderRLP(db common.Database, hash common.Hash) rlp.RawValue {
+func GetHeaderRLP(db ethdb.Database, hash common.Hash) rlp.RawValue {
data, _ := db.Get(append(append(blockPrefix, hash[:]...), headerSuffix...))
return data
}
// GetHeader retrieves the block header corresponding to the hash, nil if none
// found.
-func GetHeader(db common.Database, hash common.Hash) *types.Header {
+func GetHeader(db ethdb.Database, hash common.Hash) *types.Header {
data := GetHeaderRLP(db, hash)
if len(data) == 0 {
return nil
@@ -164,14 +165,14 @@ func GetHeader(db common.Database, hash common.Hash) *types.Header {
}
// GetBodyRLP retrieves the block body (transactions and uncles) in RLP encoding.
-func GetBodyRLP(db common.Database, hash common.Hash) rlp.RawValue {
+func GetBodyRLP(db ethdb.Database, hash common.Hash) rlp.RawValue {
data, _ := db.Get(append(append(blockPrefix, hash[:]...), bodySuffix...))
return data
}
// GetBody retrieves the block body (transactons, uncles) corresponding to the
// hash, nil if none found.
-func GetBody(db common.Database, hash common.Hash) *types.Body {
+func GetBody(db ethdb.Database, hash common.Hash) *types.Body {
data := GetBodyRLP(db, hash)
if len(data) == 0 {
return nil
@@ -186,7 +187,7 @@ func GetBody(db common.Database, hash common.Hash) *types.Body {
// GetTd retrieves a block's total difficulty corresponding to the hash, nil if
// none found.
-func GetTd(db common.Database, hash common.Hash) *big.Int {
+func GetTd(db ethdb.Database, hash common.Hash) *big.Int {
data, _ := db.Get(append(append(blockPrefix, hash.Bytes()...), tdSuffix...))
if len(data) == 0 {
return nil
@@ -201,7 +202,7 @@ func GetTd(db common.Database, hash common.Hash) *big.Int {
// GetBlock retrieves an entire block corresponding to the hash, assembling it
// back from the stored header and body.
-func GetBlock(db common.Database, hash common.Hash) *types.Block {
+func GetBlock(db ethdb.Database, hash common.Hash) *types.Block {
// Retrieve the block header and body contents
header := GetHeader(db, hash)
if header == nil {
@@ -216,7 +217,7 @@ func GetBlock(db common.Database, hash common.Hash) *types.Block {
}
// WriteCanonicalHash stores the canonical hash for the given block number.
-func WriteCanonicalHash(db common.Database, hash common.Hash, number uint64) error {
+func WriteCanonicalHash(db ethdb.Database, hash common.Hash, number uint64) error {
key := append(blockNumPrefix, big.NewInt(int64(number)).Bytes()...)
if err := db.Put(key, hash.Bytes()); err != nil {
glog.Fatalf("failed to store number to hash mapping into database: %v", err)
@@ -226,7 +227,7 @@ func WriteCanonicalHash(db common.Database, hash common.Hash, number uint64) err
}
// WriteHeadHeaderHash stores the head header's hash.
-func WriteHeadHeaderHash(db common.Database, hash common.Hash) error {
+func WriteHeadHeaderHash(db ethdb.Database, hash common.Hash) error {
if err := db.Put(headHeaderKey, hash.Bytes()); err != nil {
glog.Fatalf("failed to store last header's hash into database: %v", err)
return err
@@ -235,7 +236,7 @@ func WriteHeadHeaderHash(db common.Database, hash common.Hash) error {
}
// WriteHeadBlockHash stores the head block's hash.
-func WriteHeadBlockHash(db common.Database, hash common.Hash) error {
+func WriteHeadBlockHash(db ethdb.Database, hash common.Hash) error {
if err := db.Put(headBlockKey, hash.Bytes()); err != nil {
glog.Fatalf("failed to store last block's hash into database: %v", err)
return err
@@ -244,7 +245,7 @@ func WriteHeadBlockHash(db common.Database, hash common.Hash) error {
}
// WriteHeader serializes a block header into the database.
-func WriteHeader(db common.Database, header *types.Header) error {
+func WriteHeader(db ethdb.Database, header *types.Header) error {
data, err := rlp.EncodeToBytes(header)
if err != nil {
return err
@@ -259,7 +260,7 @@ func WriteHeader(db common.Database, header *types.Header) error {
}
// WriteBody serializes the body of a block into the database.
-func WriteBody(db common.Database, hash common.Hash, body *types.Body) error {
+func WriteBody(db ethdb.Database, hash common.Hash, body *types.Body) error {
data, err := rlp.EncodeToBytes(body)
if err != nil {
return err
@@ -274,7 +275,7 @@ func WriteBody(db common.Database, hash common.Hash, body *types.Body) error {
}
// WriteTd serializes the total difficulty of a block into the database.
-func WriteTd(db common.Database, hash common.Hash, td *big.Int) error {
+func WriteTd(db ethdb.Database, hash common.Hash, td *big.Int) error {
data, err := rlp.EncodeToBytes(td)
if err != nil {
return err
@@ -289,7 +290,7 @@ func WriteTd(db common.Database, hash common.Hash, td *big.Int) error {
}
// WriteBlock serializes a block into the database, header and body separately.
-func WriteBlock(db common.Database, block *types.Block) error {
+func WriteBlock(db ethdb.Database, block *types.Block) error {
// Store the body first to retain database consistency
if err := WriteBody(db, block.Hash(), &types.Body{block.Transactions(), block.Uncles()}); err != nil {
return err
@@ -302,27 +303,27 @@ func WriteBlock(db common.Database, block *types.Block) error {
}
// DeleteCanonicalHash removes the number to hash canonical mapping.
-func DeleteCanonicalHash(db common.Database, number uint64) {
+func DeleteCanonicalHash(db ethdb.Database, number uint64) {
db.Delete(append(blockNumPrefix, big.NewInt(int64(number)).Bytes()...))
}
// DeleteHeader removes all block header data associated with a hash.
-func DeleteHeader(db common.Database, hash common.Hash) {
+func DeleteHeader(db ethdb.Database, hash common.Hash) {
db.Delete(append(append(blockPrefix, hash.Bytes()...), headerSuffix...))
}
// DeleteBody removes all block body data associated with a hash.
-func DeleteBody(db common.Database, hash common.Hash) {
+func DeleteBody(db ethdb.Database, hash common.Hash) {
db.Delete(append(append(blockPrefix, hash.Bytes()...), bodySuffix...))
}
// DeleteTd removes all block total difficulty data associated with a hash.
-func DeleteTd(db common.Database, hash common.Hash) {
+func DeleteTd(db ethdb.Database, hash common.Hash) {
db.Delete(append(append(blockPrefix, hash.Bytes()...), tdSuffix...))
}
// DeleteBlock removes all block data associated with a hash.
-func DeleteBlock(db common.Database, hash common.Hash) {
+func DeleteBlock(db ethdb.Database, hash common.Hash) {
DeleteHeader(db, hash)
DeleteBody(db, hash)
DeleteTd(db, hash)
@@ -333,7 +334,7 @@ func DeleteBlock(db common.Database, hash common.Hash) {
// or nil if not found. This method is only used by the upgrade mechanism to
// access the old combined block representation. It will be dropped after the
// network transitions to eth/63.
-func GetBlockByHashOld(db common.Database, hash common.Hash) *types.Block {
+func GetBlockByHashOld(db ethdb.Database, hash common.Hash) *types.Block {
data, _ := db.Get(append(blockHashPre, hash[:]...))
if len(data) == 0 {
return nil
diff --git a/core/genesis.go b/core/genesis.go
index 3a8f0af0c..727e2c75f 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -27,13 +27,14 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/params"
)
// WriteGenesisBlock writes the genesis block to the database as block number 0
-func WriteGenesisBlock(chainDb common.Database, reader io.Reader) (*types.Block, error) {
+func WriteGenesisBlock(chainDb ethdb.Database, reader io.Reader) (*types.Block, error) {
contents, err := ioutil.ReadAll(reader)
if err != nil {
return nil, err
@@ -110,7 +111,7 @@ func WriteGenesisBlock(chainDb common.Database, reader io.Reader) (*types.Block,
// GenesisBlockForTesting creates a block in which addr has the given wei balance.
// The state trie of the block is written to db.
-func GenesisBlockForTesting(db common.Database, addr common.Address, balance *big.Int) *types.Block {
+func GenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block {
statedb := state.New(common.Hash{}, db)
obj := statedb.GetOrNewStateObject(addr)
obj.SetBalance(balance)
@@ -124,7 +125,7 @@ func GenesisBlockForTesting(db common.Database, addr common.Address, balance *bi
return block
}
-func WriteGenesisBlockForTesting(db common.Database, addr common.Address, balance *big.Int) *types.Block {
+func WriteGenesisBlockForTesting(db ethdb.Database, addr common.Address, balance *big.Int) *types.Block {
testGenesis := fmt.Sprintf(`{
"nonce":"0x%x",
"gasLimit":"0x%x",
@@ -137,7 +138,7 @@ func WriteGenesisBlockForTesting(db common.Database, addr common.Address, balanc
return block
}
-func WriteTestNetGenesisBlock(chainDb common.Database, nonce uint64) (*types.Block, error) {
+func WriteTestNetGenesisBlock(chainDb ethdb.Database, nonce uint64) (*types.Block, error) {
testGenesis := fmt.Sprintf(`{
"nonce":"0x%x",
"gasLimit":"0x%x",
diff --git a/core/helper_test.go b/core/helper_test.go
index b21f31d7c..81ea6fc22 100644
--- a/core/helper_test.go
+++ b/core/helper_test.go
@@ -22,7 +22,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
// "github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/common"
+
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
)
@@ -32,7 +32,7 @@ type TestManager struct {
// stateManager *StateManager
eventMux *event.TypeMux
- db common.Database
+ db ethdb.Database
txPool *TxPool
blockChain *ChainManager
Blocks []*types.Block
@@ -74,7 +74,7 @@ func (tm *TestManager) EventMux() *event.TypeMux {
// return nil
// }
-func (tm *TestManager) Db() common.Database {
+func (tm *TestManager) Db() ethdb.Database {
return tm.db
}
diff --git a/core/manager.go b/core/manager.go
index 8b0401b03..0f108a6de 100644
--- a/core/manager.go
+++ b/core/manager.go
@@ -18,7 +18,7 @@ package core
import (
"github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
)
@@ -28,7 +28,7 @@ type Backend interface {
BlockProcessor() *BlockProcessor
ChainManager() *ChainManager
TxPool() *TxPool
- ChainDb() common.Database
- DappDb() common.Database
+ ChainDb() ethdb.Database
+ DappDb() ethdb.Database
EventMux() *event.TypeMux
}
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 69c64ae40..353f2357b 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/rlp"
@@ -56,7 +57,7 @@ func (self Storage) Copy() Storage {
type StateObject struct {
// State database for storing state changes
- db common.Database
+ db ethdb.Database
trie *trie.SecureTrie
// Address belonging to this account
@@ -87,7 +88,7 @@ type StateObject struct {
dirty bool
}
-func NewStateObject(address common.Address, db common.Database) *StateObject {
+func NewStateObject(address common.Address, db ethdb.Database) *StateObject {
object := &StateObject{db: db, address: address, balance: new(big.Int), gasPool: new(big.Int), dirty: true}
object.trie = trie.NewSecure((common.Hash{}).Bytes(), db)
object.storage = make(Storage)
@@ -96,7 +97,7 @@ func NewStateObject(address common.Address, db common.Database) *StateObject {
return object
}
-func NewStateObjectFromBytes(address common.Address, data []byte, db common.Database) *StateObject {
+func NewStateObjectFromBytes(address common.Address, data []byte, db ethdb.Database) *StateObject {
// TODO clean me up
var extobject struct {
Nonce uint64
diff --git a/core/state/statedb.go b/core/state/statedb.go
index b754f0887..24f97e32a 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -21,6 +21,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/trie"
@@ -32,7 +33,7 @@ import (
// * Contracts
// * Accounts
type StateDB struct {
- db common.Database
+ db ethdb.Database
trie *trie.SecureTrie
root common.Hash
@@ -47,7 +48,7 @@ type StateDB struct {
}
// Create a new state from a given trie
-func New(root common.Hash, db common.Database) *StateDB {
+func New(root common.Hash, db ethdb.Database) *StateDB {
trie := trie.NewSecure(root[:], db)
return &StateDB{root: root, db: db, trie: trie, stateObjects: make(map[string]*StateObject), refund: new(big.Int), logs: make(map[common.Hash]Logs)}
}
diff --git a/core/transaction_util.go b/core/transaction_util.go
index ce2ceac46..69c6bc36f 100644
--- a/core/transaction_util.go
+++ b/core/transaction_util.go
@@ -32,7 +32,7 @@ var (
)
// PutTransactions stores the transactions in the given database
-func PutTransactions(db common.Database, block *types.Block, txs types.Transactions) {
+func PutTransactions(db ethdb.Database, block *types.Block, txs types.Transactions) {
batch := new(leveldb.Batch)
_, batchWrite := db.(*ethdb.LDBDatabase)
@@ -78,7 +78,7 @@ func PutTransactions(db common.Database, block *types.Block, txs types.Transacti
}
// PutReceipts stores the receipts in the current database
-func PutReceipts(db common.Database, receipts types.Receipts) error {
+func PutReceipts(db ethdb.Database, receipts types.Receipts) error {
batch := new(leveldb.Batch)
_, batchWrite := db.(*ethdb.LDBDatabase)
@@ -108,7 +108,7 @@ func PutReceipts(db common.Database, receipts types.Receipts) error {
}
// GetReceipt returns a receipt by hash
-func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt {
+func GetReceipt(db ethdb.Database, txHash common.Hash) *types.Receipt {
data, _ := db.Get(append(receiptsPre, txHash[:]...))
if len(data) == 0 {
return nil
@@ -124,7 +124,7 @@ func GetReceipt(db common.Database, txHash common.Hash) *types.Receipt {
// GetBlockReceipts returns the receipts generated by the transactions
// included in block's given hash.
-func GetBlockReceipts(db common.Database, hash common.Hash) types.Receipts {
+func GetBlockReceipts(db ethdb.Database, hash common.Hash) types.Receipts {
data, _ := db.Get(append(blockReceiptsPre, hash[:]...))
if len(data) == 0 {
return nil
@@ -141,7 +141,7 @@ func GetBlockReceipts(db common.Database, hash common.Hash) types.Receipts {
// PutBlockReceipts stores the block's transactions associated receipts
// and stores them by block hash in a single slice. This is required for
// forks and chain reorgs
-func PutBlockReceipts(db common.Database, block *types.Block, receipts types.Receipts) error {
+func PutBlockReceipts(db ethdb.Database, block *types.Block, receipts types.Receipts) error {
rs := make([]*types.ReceiptForStorage, len(receipts))
for i, receipt := range receipts {
rs[i] = (*types.ReceiptForStorage)(receipt)