From 57935425fd929dd5642bd5a9e1e31ec90c4ebb20 Mon Sep 17 00:00:00 2001 From: Nick Johnson Date: Wed, 11 Jan 2017 09:51:44 +0000 Subject: [PATCH] core, eth, ethdb, internal: Changes in response to review --- core/database_util.go | 6 +++--- core/state/statedb.go | 2 ++ eth/api.go | 2 +- internal/web3ext/web3ext.go | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/database_util.go b/core/database_util.go index 919f402fad..001ec34b60 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -600,12 +600,12 @@ func GetMipmapBloom(db ethdb.Database, number, level uint64) types.Bloom { return types.BytesToBloom(bloomDat) } -func GetPreimageTable(db ethdb.Database) ethdb.Database { - return ethdb.NewDatabaseTable(db, preimagePrefix) +func PreimageTable(db ethdb.Database) ethdb.Database { + return ethdb.NewTable(db, preimagePrefix) } func WritePreimages(db ethdb.Database, number uint64, preimages map[common.Hash][]byte) error { - table := GetPreimageTable(db) + table := PreimageTable(db) batch := table.NewBatch() hitCount := 0 for hash, preimage := range preimages { diff --git a/core/state/statedb.go b/core/state/statedb.go index 9bf32a4870..bbccba9fba 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -204,6 +204,7 @@ func (self *StateDB) Logs() []*types.Log { return logs } +// AddPreimage records a SHA3 preimage seen by the VM. func (self *StateDB) AddPreimage(hash common.Hash, preimage []byte) { if _, ok := self.preimages[hash]; !ok { self.journal = append(self.journal, addPreimageChange{hash: hash}) @@ -213,6 +214,7 @@ func (self *StateDB) AddPreimage(hash common.Hash, preimage []byte) { } } +// Preimages returns a list of SHA3 preimages that have been submitted. func (self *StateDB) Preimages() map[common.Hash][]byte { return self.preimages } diff --git a/eth/api.go b/eth/api.go index 5fc071180c..4d059c2c27 100644 --- a/eth/api.go +++ b/eth/api.go @@ -562,6 +562,6 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, txHash common. } func (api *PrivateDebugAPI) GetPreimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { - db := core.GetPreimageTable(api.eth.ChainDb()) + db := core.PreimageTable(api.eth.ChainDb()) return db.Get(hash.Bytes()) } diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 859c4f614b..dfd14da984 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -388,7 +388,7 @@ web3._extend({ }), new web3._extend.Method({ name: 'getPreimage', - call: 'debug_getPreimage', + call: 'debug_preimage', params: 1, inputFormatter: [null] })