fix: change append with put. Some nit comments (#1070)

This commit is contained in:
rakita
2023-01-29 11:43:21 +01:00
committed by GitHub
parent e9228227d3
commit 17c1549eaf
4 changed files with 13 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ use crate::{
db::Transaction, ExecInput, ExecOutput, Stage, StageError, StageId, UnwindInput, UnwindOutput,
};
use reth_db::{
cursor::{DbCursorRO, DbCursorRW},
cursor::DbCursorRO,
database::Database,
tables,
transaction::{DbTx, DbTxMut},
@@ -76,9 +76,10 @@ impl<DB: Database> Stage<DB> for AccountHashingStage {
// next key of iterator
let next_key = accounts.next()?;
let mut hashes = tx.cursor_write::<tables::HashedAccount>()?;
// iterate and append presorted hashed accounts
hashed_batch.into_iter().try_for_each(|(k, v)| hashes.append(k, v))?;
// iterate and put presorted hashed accounts
hashed_batch
.into_iter()
.try_for_each(|(k, v)| tx.put::<tables::HashedAccount>(k, v))?;
next_key
};
tx.commit()?;

View File

@@ -80,9 +80,10 @@ impl<DB: Database> Stage<DB> for StorageHashingStage {
// next key of iterator
let next_key = storage.next()?;
let mut hashes = tx.cursor_write::<tables::HashedStorage>()?;
// iterate and append presorted hashed slots
hashed_batch.into_iter().try_for_each(|(k, v)| hashes.append(k, v))?;
// iterate and put presorted hashed slots
hashed_batch
.into_iter()
.try_for_each(|(k, v)| tx.put::<tables::HashedStorage>(k, v))?;
next_key
};
tx.commit()?;

View File

@@ -16,8 +16,8 @@ use tracing::*;
const INDEX_ACCOUNT_HISTORY: StageId = StageId("IndexAccountHistoryStage");
/// Account hashing stage hashes plain account.
/// This is preparation before generating intermediate hashes and calculating Merkle tree root.
/// Stage is indexing history the account changesets generated in [`ExecutionStage`]
/// For more information on index sharding please look at [`tables::AccountHistory`]
#[derive(Debug)]
pub struct IndexAccountHistoryStage {
/// Number of blocks after which the control

View File

@@ -16,8 +16,8 @@ use tracing::*;
const INDEX_STORAGE_HISTORY: StageId = StageId("IndexStorageHistoryStage");
/// Account hashing stage hashes plain account.
/// This is preparation before generating intermediate hashes and calculating Merkle tree root.
/// Stage is indexing history the account changesets generated in [`ExecutionStage`]
/// For more information on index sharding please look at [`tables::StorageHistory`]
#[derive(Debug)]
pub struct IndexStorageHistoryStage {
/// Number of blocks after which the control