core/rawdb, cmd/utils: fix review concerns

This commit is contained in:
Martin Holst Swende 2020-03-17 20:55:56 +01:00
parent 72d41b7029
commit b1862e1495
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
5 changed files with 9 additions and 9 deletions

View file

@ -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{

View file

@ -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

View file

@ -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)
}
}

View file

@ -18,7 +18,6 @@ package rawdb
import (
"math"
"math/big"
"runtime"
"sync/atomic"
"time"
@ -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

View file

@ -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 (