mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core/rawdb, cmd/utils: fix review concerns
This commit is contained in:
parent
72d41b7029
commit
b1862e1495
5 changed files with 9 additions and 9 deletions
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Reference in a new issue