diff --git a/core/database_util.go b/core/database_util.go index 001ec34b60..229f21b5b7 100644 --- a/core/database_util.go +++ b/core/database_util.go @@ -600,10 +600,13 @@ func GetMipmapBloom(db ethdb.Database, number, level uint64) types.Bloom { return types.BytesToBloom(bloomDat) } +// PreimageTable returns a Database instance with the key prefix for preimage entries. func PreimageTable(db ethdb.Database) ethdb.Database { return ethdb.NewTable(db, preimagePrefix) } +// WritePreimages writes the provided set of preimages to the database. `number` is the +// current block number, and is used for debug messages only. func WritePreimages(db ethdb.Database, number uint64, preimages map[common.Hash][]byte) error { table := PreimageTable(db) batch := table.NewBatch() @@ -620,7 +623,7 @@ func WritePreimages(db ethdb.Database, number uint64, preimages map[common.Hash] if err := batch.Write(); err != nil { return fmt.Errorf("preimage write fail for block %d: %v", number, err) } - glog.V(logger.Error).Infof("%d preimages in block %d, including %d new", len(preimages), number, hitCount) + glog.V(logger.Debug).Infof("%d preimages in block %d, including %d new", len(preimages), number, hitCount) } return nil } diff --git a/eth/api.go b/eth/api.go index c99cac792b..5d7857d1e2 100644 --- a/eth/api.go +++ b/eth/api.go @@ -561,6 +561,7 @@ func (api *PrivateDebugAPI) TraceTransaction(ctx context.Context, txHash common. return nil, errors.New("database inconsistency") } +// Preimage is a debug API function that returns the preimage for a sha3 hash, if known. func (api *PrivateDebugAPI) Preimage(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { db := core.PreimageTable(api.eth.ChainDb()) return db.Get(hash.Bytes())