Skip to content

Commit

Permalink
core, eth: Doc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachnid committed Jan 12, 2017
1 parent f19241b commit faafd42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/database_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit faafd42

Please sign in to comment.