Skip to content

Commit

Permalink
core/rawdb, cmd/utils: fix review concerns
Browse files Browse the repository at this point in the history
  • Loading branch information
holiman committed Apr 7, 2020
1 parent 72d41b7 commit b1862e1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ var (
}
TxLookupLimitFlag = cli.Int64Flag{
Name: "txlookuplimit",
Usage: "Number of recent blocks to index transactions-by-hash in (default = index all blocks)",
Usage: "Number of recent blocks to maintain transactions index by-hash for (default = index all blocks)",
Value: 0,
}
LightKDFFlag = cli.BoolFlag{
Expand Down
4 changes: 2 additions & 2 deletions core/rawdb/accessors_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ func ReadBodyRLP(db ethdb.Reader, hash common.Hash, number uint64) rlp.RawValue
}

// ReadCanonicalBodyRLP retrieves the block body (transactions and uncles) for the canonical
// bloc at number, in RLP encoding.
// block at number, in RLP encoding.
func ReadCanonicalBodyRLP(db ethdb.Reader, number uint64) rlp.RawValue {
// if it's an ancient one, we don't need the canonical hash
// If it's an ancient one, we don't need the canonical hash
data, _ := db.Ancient(freezerBodiesTable, number)
if len(data) == 0 {
// Need to get the hash
Expand Down
7 changes: 4 additions & 3 deletions core/rawdb/accessors_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ func WriteTxLookupEntries(db ethdb.KeyValueWriter, block *types.Block) {
}

// WriteTxLookupEntriesByHash is identical to WriteTxLookupEntries, but does not
// require a full types.Block as input
func WriteTxLookupEntriesByHash(db ethdb.KeyValueWriter, number []byte, hashes []common.Hash) {
// require a full types.Block as input.
func WriteTxLookupEntriesByHash(db ethdb.KeyValueWriter, number uint64, hashes []common.Hash) {
numberBytes := new(big.Int).SetUint64(number).Bytes()
for _, hash := range hashes {
if err := db.Put(txLookupKey(hash), number); err != nil {
if err := db.Put(txLookupKey(hash), numberBytes); err != nil {
log.Crit("Failed to store transaction lookup entry", "err", err)
}
}
Expand Down
4 changes: 1 addition & 3 deletions core/rawdb/chain_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package rawdb

import (
"math"
"math/big"
"runtime"
"sync/atomic"
"time"
Expand Down Expand Up @@ -220,8 +219,7 @@ func IndexTransactions(db ethdb.Database, from uint64, to uint64) {
// Next block available, pop it off and index it
delivery := queue.PopItem().(*blockTxHashes)
lastNum = delivery.number
number := new(big.Int).SetUint64(lastNum).Bytes()
WriteTxLookupEntriesByHash(batch, number, delivery.hashes)
WriteTxLookupEntriesByHash(batch, delivery.number, delivery.hashes)
blockCount++
txCount += len(delivery.hashes)
// If enough data was accumulated in memory or we're at the last block, dump to disk
Expand Down
1 change: 1 addition & 0 deletions core/rlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package core

import (
Expand Down

0 comments on commit b1862e1

Please sign in to comment.