Rename cursor functions (#787)

This commit is contained in:
LambdaClass
2023-01-10 16:08:30 -03:00
committed by GitHub
parent e5e74cbc02
commit 3bd1458df6
17 changed files with 90 additions and 90 deletions

View File

@ -26,7 +26,7 @@ pub fn init_db<P: AsRef<Path>>(path: P) -> eyre::Result<Env<WriteMap>> {
#[allow(clippy::field_reassign_with_default)]
pub fn init_genesis<DB: Database>(db: Arc<DB>, genesis: Genesis) -> Result<H256, reth_db::Error> {
let tx = db.tx()?;
if let Some((_, hash)) = tx.cursor::<tables::CanonicalHeaders>()?.first()? {
if let Some((_, hash)) = tx.cursor_read::<tables::CanonicalHeaders>()?.first()? {
debug!("Genesis already written, skipping.");
return Ok(hash)
}

View File

@ -207,7 +207,7 @@ where
T: Table,
F: FnMut(T::Key) -> BlockNumber,
{
let mut cursor = self.cursor_mut::<T>()?;
let mut cursor = self.cursor_write::<T>()?;
let mut entry = cursor.last()?;
while let Some((key, _)) = entry {
if selector(key) <= block {
@ -226,7 +226,7 @@ where
T1: Table,
T2: Table<Key = T1::Value>,
{
let mut cursor = self.cursor_mut::<T1>()?;
let mut cursor = self.cursor_write::<T1>()?;
let mut walker = cursor.walk(start_at)?;
while let Some((_, value)) = walker.next().transpose()? {
self.delete::<T2>(value, None)?;

View File

@ -84,13 +84,13 @@ impl<DB: Database, D: BodyDownloader, C: Consensus> Stage<DB> for BodyStage<D, C
let bodies_to_download = self.bodies_to_download::<DB>(tx, start_block, end_block)?;
// Cursors used to write bodies, ommers and transactions
let mut body_cursor = tx.cursor_mut::<tables::BlockBodies>()?;
let mut ommers_cursor = tx.cursor_mut::<tables::BlockOmmers>()?;
let mut tx_cursor = tx.cursor_mut::<tables::Transactions>()?;
let mut body_cursor = tx.cursor_write::<tables::BlockBodies>()?;
let mut ommers_cursor = tx.cursor_write::<tables::BlockOmmers>()?;
let mut tx_cursor = tx.cursor_write::<tables::Transactions>()?;
// Cursors used to write state transition mapping
let mut block_transition_cursor = tx.cursor_mut::<tables::BlockTransitionIndex>()?;
let mut tx_transition_cursor = tx.cursor_mut::<tables::TxTransitionIndex>()?;
let mut block_transition_cursor = tx.cursor_write::<tables::BlockTransitionIndex>()?;
let mut tx_transition_cursor = tx.cursor_write::<tables::TxTransitionIndex>()?;
// Get id for the first transaction and first transition in the block
let (mut current_tx_id, mut transition_id) = tx.get_next_block_ids(start_block)?;
@ -185,13 +185,13 @@ impl<DB: Database, D: BodyDownloader, C: Consensus> Stage<DB> for BodyStage<D, C
) -> Result<UnwindOutput, StageError> {
info!(target: "sync::stages::bodies", to_block = input.unwind_to, "Unwinding");
// Cursors to unwind bodies, ommers, transactions and tx hash to number
let mut body_cursor = tx.cursor_mut::<tables::BlockBodies>()?;
let mut ommers_cursor = tx.cursor_mut::<tables::BlockOmmers>()?;
let mut transaction_cursor = tx.cursor_mut::<tables::Transactions>()?;
let mut tx_hash_number_cursor = tx.cursor_mut::<tables::TxHashNumber>()?;
let mut body_cursor = tx.cursor_write::<tables::BlockBodies>()?;
let mut ommers_cursor = tx.cursor_write::<tables::BlockOmmers>()?;
let mut transaction_cursor = tx.cursor_write::<tables::Transactions>()?;
let mut tx_hash_number_cursor = tx.cursor_write::<tables::TxHashNumber>()?;
// Cursors to unwind transitions
let mut block_transition_cursor = tx.cursor_mut::<tables::BlockTransitionIndex>()?;
let mut tx_transition_cursor = tx.cursor_mut::<tables::TxTransitionIndex>()?;
let mut block_transition_cursor = tx.cursor_write::<tables::BlockTransitionIndex>()?;
let mut tx_transition_cursor = tx.cursor_write::<tables::TxTransitionIndex>()?;
let mut entry = body_cursor.last()?;
while let Some((key, body)) = entry {
@ -245,8 +245,8 @@ impl<D: BodyDownloader, C: Consensus> BodyStage<D, C> {
starting_block: BlockNumber,
target: BlockNumber,
) -> Result<Vec<SealedHeader>, StageError> {
let mut header_cursor = tx.cursor::<tables::Headers>()?;
let mut header_hashes_cursor = tx.cursor::<tables::CanonicalHeaders>()?;
let mut header_cursor = tx.cursor_read::<tables::Headers>()?;
let mut header_hashes_cursor = tx.cursor_read::<tables::CanonicalHeaders>()?;
let mut walker = header_hashes_cursor
.walk(starting_block)?
.take_while(|item| item.as_ref().map_or(false, |(num, _)| *num <= target));
@ -454,7 +454,7 @@ mod tests {
runner
.tx()
.commit(|tx| {
let mut tx_cursor = tx.cursor_mut::<tables::Transactions>()?;
let mut tx_cursor = tx.cursor_write::<tables::Transactions>()?;
let (_, transaction) = tx_cursor.last()?.expect("Could not read last transaction");
tx_cursor.delete_current()?;
tx.delete::<tables::TxHashNumber>(transaction.hash, None)?;
@ -689,7 +689,7 @@ mod tests {
/// Get the last available tx id if any
pub(crate) fn get_last_tx_id(&self) -> Result<Option<TxNumber>, TestRunnerError> {
let last_body = self.tx.query(|tx| {
let v = tx.cursor::<tables::BlockBodies>()?.last()?;
let v = tx.cursor_read::<tables::BlockBodies>()?.last()?;
Ok(v)
})?;
Ok(match last_body {
@ -708,12 +708,12 @@ mod tests {
) -> Result<(), TestRunnerError> {
self.tx.query(|tx| {
// Acquire cursors on body related tables
let mut bodies_cursor = tx.cursor::<tables::BlockBodies>()?;
let mut ommers_cursor = tx.cursor::<tables::BlockOmmers>()?;
let mut block_transition_cursor = tx.cursor::<tables::BlockTransitionIndex>()?;
let mut transaction_cursor = tx.cursor::<tables::Transactions>()?;
let mut tx_hash_num_cursor = tx.cursor::<tables::TxHashNumber>()?;
let mut tx_transition_cursor = tx.cursor::<tables::TxTransitionIndex>()?;
let mut bodies_cursor = tx.cursor_read::<tables::BlockBodies>()?;
let mut ommers_cursor = tx.cursor_read::<tables::BlockOmmers>()?;
let mut block_transition_cursor = tx.cursor_read::<tables::BlockTransitionIndex>()?;
let mut transaction_cursor = tx.cursor_read::<tables::Transactions>()?;
let mut tx_hash_num_cursor = tx.cursor_read::<tables::TxHashNumber>()?;
let mut tx_transition_cursor = tx.cursor_read::<tables::TxTransitionIndex>()?;
let first_body_key = match bodies_cursor.first()? {
Some((key, _)) => key,

View File

@ -91,17 +91,17 @@ impl<DB: Database> Stage<DB> for ExecutionStage {
let last_block = input.stage_progress.unwrap_or_default();
// Get next canonical block hashes to execute.
let mut canonicals = tx.cursor::<tables::CanonicalHeaders>()?;
let mut canonicals = tx.cursor_read::<tables::CanonicalHeaders>()?;
// Get header with canonical hashes.
let mut headers = tx.cursor::<tables::Headers>()?;
let mut headers = tx.cursor_read::<tables::Headers>()?;
// Get bodies with canonical hashes.
let mut bodies_cursor = tx.cursor::<tables::BlockBodies>()?;
let mut bodies_cursor = tx.cursor_read::<tables::BlockBodies>()?;
// Get ommers with canonical hashes.
let mut ommers_cursor = tx.cursor::<tables::BlockOmmers>()?;
let mut ommers_cursor = tx.cursor_read::<tables::BlockOmmers>()?;
// Get transaction of the block that we are executing.
let mut tx_cursor = tx.cursor::<tables::Transactions>()?;
let mut tx_cursor = tx.cursor_read::<tables::Transactions>()?;
// Skip sender recovery and load signer from database.
let mut tx_sender = tx.cursor::<tables::TxSenders>()?;
let mut tx_sender = tx.cursor_read::<tables::TxSenders>()?;
// get canonical blocks (num,hash)
let canonical_batch = canonicals
@ -294,8 +294,8 @@ impl<DB: Database> Stage<DB> for ExecutionStage {
info!(target: "sync::stages::execution", to_block = input.unwind_to, "Unwinding");
// Acquire changeset cursors
let mut account_changeset = tx.cursor_dup_mut::<tables::AccountChangeSet>()?;
let mut storage_changeset = tx.cursor_dup_mut::<tables::StorageChangeSet>()?;
let mut account_changeset = tx.cursor_dup_write::<tables::AccountChangeSet>()?;
let mut storage_changeset = tx.cursor_dup_write::<tables::StorageChangeSet>()?;
let from_transition_rev = tx.get_block_transition_by_num(input.unwind_to)? + 1;
let to_transition_rev = tx.get_block_transition_by_num(input.stage_progress)? + 1;

View File

@ -107,7 +107,7 @@ impl<DB: Database, D: HeaderDownloader, C: Consensus, H: HeadersClient, S: Statu
if self.is_stage_done(tx, current_progress).await? {
let stage_progress = current_progress.max(
tx.cursor::<tables::CanonicalHeaders>()?
tx.cursor_read::<tables::CanonicalHeaders>()?
.last()?
.map(|(num, _)| num)
.unwrap_or_default(),
@ -176,7 +176,7 @@ impl<D: HeaderDownloader, C: Consensus, H: HeadersClient, S: StatusUpdater>
tx: &Transaction<'_, DB>,
stage_progress: u64,
) -> Result<bool, StageError> {
let mut header_cursor = tx.cursor::<tables::CanonicalHeaders>()?;
let mut header_cursor = tx.cursor_read::<tables::CanonicalHeaders>()?;
let (head_num, _) = header_cursor
.seek_exact(stage_progress)?
.ok_or(DatabaseIntegrityError::CanonicalHeader { number: stage_progress })?;
@ -191,8 +191,8 @@ impl<D: HeaderDownloader, C: Consensus, H: HeadersClient, S: StatusUpdater>
stage_progress: u64,
) -> Result<(SealedHeader, H256), StageError> {
// Create a cursor over canonical header hashes
let mut cursor = tx.cursor::<tables::CanonicalHeaders>()?;
let mut header_cursor = tx.cursor::<tables::Headers>()?;
let mut cursor = tx.cursor_read::<tables::CanonicalHeaders>()?;
let mut header_cursor = tx.cursor_read::<tables::Headers>()?;
// Get head hash and reposition the cursor
let (head_num, head_hash) = cursor
@ -259,8 +259,8 @@ impl<D: HeaderDownloader, C: Consensus, H: HeadersClient, S: StatusUpdater>
tx: &Transaction<'_, DB>,
headers: Vec<SealedHeader>,
) -> Result<Option<BlockNumber>, StageError> {
let mut cursor_header = tx.cursor_mut::<tables::Headers>()?;
let mut cursor_canonical = tx.cursor_mut::<tables::CanonicalHeaders>()?;
let mut cursor_header = tx.cursor_write::<tables::Headers>()?;
let mut cursor_canonical = tx.cursor_write::<tables::CanonicalHeaders>()?;
let mut latest = None;
// Since the headers were returned in descending order,

View File

@ -76,10 +76,10 @@ impl<DB: Database> Stage<DB> for SenderRecoveryStage {
}
// Acquire the cursor for inserting elements
let mut senders_cursor = tx.cursor_mut::<tables::TxSenders>()?;
let mut senders_cursor = tx.cursor_write::<tables::TxSenders>()?;
// Acquire the cursor over the transactions
let mut tx_cursor = tx.cursor::<tables::Transactions>()?;
let mut tx_cursor = tx.cursor_read::<tables::Transactions>()?;
// Walk the transactions from start to end index (inclusive)
let entries = tx_cursor
.walk(start_tx_index)?
@ -278,7 +278,7 @@ mod tests {
}
let start_hash = tx.get::<tables::CanonicalHeaders>(start_block)?.unwrap();
let mut body_cursor = tx.cursor::<tables::BlockBodies>()?;
let mut body_cursor = tx.cursor_read::<tables::BlockBodies>()?;
body_cursor.seek_exact((start_block, start_hash).into())?;
while let Some((_, body)) = body_cursor.next()? {

View File

@ -43,8 +43,8 @@ impl<DB: Database> Stage<DB> for TotalDifficultyStage {
debug!(target: "sync::stages::total_difficulty", start_block, end_block, "Commencing sync");
// Acquire cursor over total difficulty and headers tables
let mut cursor_td = tx.cursor_mut::<tables::HeaderTD>()?;
let mut cursor_headers = tx.cursor_mut::<tables::Headers>()?;
let mut cursor_td = tx.cursor_write::<tables::HeaderTD>()?;
let mut cursor_headers = tx.cursor_write::<tables::Headers>()?;
// Get latest total difficulty
let last_header_key = tx.get_block_numhash(input.stage_progress.unwrap_or_default())?;
@ -124,7 +124,7 @@ mod tests {
self.tx.insert_headers(std::iter::once(&head))?;
self.tx.commit(|tx| {
let td: U256 = tx
.cursor::<tables::HeaderTD>()?
.cursor_read::<tables::HeaderTD>()?
.last()?
.map(|(_, v)| v)
.unwrap_or_default()
@ -159,7 +159,7 @@ mod tests {
.get::<tables::CanonicalHeaders>(initial_stage_progress)?
.expect("no initial header hash");
let start_key = (initial_stage_progress, start_hash).into();
let mut header_cursor = tx.cursor::<tables::Headers>()?;
let mut header_cursor = tx.cursor_read::<tables::Headers>()?;
let (_, mut current_header) =
header_cursor.seek_exact(start_key)?.expect("no initial header");
let mut td: U256 =

View File

@ -63,7 +63,7 @@ impl TestTransaction {
/// Check if the table is empty
pub(crate) fn table_is_empty<T: Table>(&self) -> Result<bool, DbError> {
self.query(|tx| {
let last = tx.cursor::<T>()?.last()?;
let last = tx.cursor_read::<T>()?.last()?;
Ok(last.is_none())
})
}
@ -112,7 +112,7 @@ impl TestTransaction {
F: FnMut(&Option<<T as Table>::Value>, &S) -> (T::Key, T::Value),
{
self.commit(|tx| {
let mut cursor = tx.cursor_mut::<T>()?;
let mut cursor = tx.cursor_write::<T>()?;
let mut last = cursor.last()?.map(|(_, v)| v);
values.iter().try_for_each(|src| {
let (k, v) = transform(&last, src);
@ -134,7 +134,7 @@ impl TestTransaction {
F: FnMut(T::Key) -> BlockNumber,
{
self.query(|tx| {
let mut cursor = tx.cursor::<T>()?;
let mut cursor = tx.cursor_read::<T>()?;
if let Some((key, _)) = cursor.last()? {
assert!(selector(key) <= num);
}
@ -154,7 +154,7 @@ impl TestTransaction {
F: FnMut(T::Value) -> BlockNumber,
{
self.query(|tx| {
let mut cursor = tx.cursor::<T>()?;
let mut cursor = tx.cursor_read::<T>()?;
let mut entry = cursor.last()?;
while let Some((_, value)) = entry {
assert!(selector(value) <= num);

View File

@ -60,11 +60,11 @@ impl<'a> DbTx<'a> for TxMock {
todo!()
}
fn cursor<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, Error> {
fn cursor_read<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, Error> {
todo!()
}
fn cursor_dup<T: DupSort>(&self) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, Error> {
fn cursor_dup_read<T: DupSort>(&self) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, Error> {
todo!()
}
}
@ -78,11 +78,11 @@ impl<'a> DbTxMut<'a> for TxMock {
todo!()
}
fn cursor_mut<T: Table>(&self) -> Result<<Self as DbTxMutGAT<'_>>::CursorMut<T>, Error> {
fn cursor_write<T: Table>(&self) -> Result<<Self as DbTxMutGAT<'_>>::CursorMut<T>, Error> {
todo!()
}
fn cursor_dup_mut<T: DupSort>(
fn cursor_dup_write<T: DupSort>(
&self,
) -> Result<<Self as DbTxMutGAT<'_>>::DupCursorMut<T>, Error> {
todo!()

View File

@ -40,9 +40,9 @@ pub trait DbTx<'tx>: for<'a> DbTxGAT<'a> {
/// freeing of memory pages
fn commit(self) -> Result<bool, Error>;
/// Iterate over read only values in table.
fn cursor<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, Error>;
fn cursor_read<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, Error>;
/// Iterate over read only values in dup sorted table.
fn cursor_dup<T: DupSort>(&self) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, Error>;
fn cursor_dup_read<T: DupSort>(&self) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, Error>;
}
/// Read write transaction that allows writing to database
@ -54,9 +54,9 @@ pub trait DbTxMut<'tx>: for<'a> DbTxMutGAT<'a> {
/// Clears database.
fn clear<T: Table>(&self) -> Result<(), Error>;
/// Cursor mut
fn cursor_mut<T: Table>(&self) -> Result<<Self as DbTxMutGAT<'_>>::CursorMut<T>, Error>;
fn cursor_write<T: Table>(&self) -> Result<<Self as DbTxMutGAT<'_>>::CursorMut<T>, Error>;
/// DupCursor mut.
fn cursor_dup_mut<T: DupSort>(
fn cursor_dup_write<T: DupSort>(
&self,
) -> Result<<Self as DbTxMutGAT<'_>>::DupCursorMut<T>, Error>;
}

View File

@ -202,7 +202,7 @@ mod tests {
// Cursor
let tx = env.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor::<Headers>().unwrap();
let mut cursor = tx.cursor_read::<Headers>().unwrap();
let first = cursor.first().unwrap();
assert!(first.is_some(), "First should be our put");
@ -228,7 +228,7 @@ mod tests {
// Cursor
let missing_key = 2;
let tx = db.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor::<CanonicalHeaders>().unwrap();
let mut cursor = tx.cursor_read::<CanonicalHeaders>().unwrap();
assert_eq!(cursor.current(), Ok(None));
// Seek exact
@ -255,7 +255,7 @@ mod tests {
let key_to_insert = 2;
let tx = db.tx_mut().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_mut::<CanonicalHeaders>().unwrap();
let mut cursor = tx.cursor_write::<CanonicalHeaders>().unwrap();
// INSERT
cursor.seek_exact(1).unwrap();
@ -282,7 +282,7 @@ mod tests {
// APPEND
let key_to_append = 2;
let tx = db.tx_mut().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_mut::<CanonicalHeaders>().unwrap();
let mut cursor = tx.cursor_write::<CanonicalHeaders>().unwrap();
cursor.seek_exact(1).unwrap();
assert_eq!(cursor.append(key_to_append, H256::zero()), Err(Error::Write(4294936878)));
assert_eq!(cursor.current(), Ok(Some((5, H256::zero())))); // the end of table
@ -344,7 +344,7 @@ mod tests {
// Iterate with cursor
{
let tx = env.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_dup::<PlainStorageState>().unwrap();
let mut cursor = tx.cursor_dup_read::<PlainStorageState>().unwrap();
// Notice that value11 and value22 have been ordered in the DB.
assert!(Some(value00) == cursor.next_dup_val().unwrap());
@ -355,7 +355,7 @@ mod tests {
// Seek value with exact subkey
{
let tx = env.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_dup::<PlainStorageState>().unwrap();
let mut cursor = tx.cursor_dup_read::<PlainStorageState>().unwrap();
let mut walker = cursor.walk_dup(key, H256::from_low_u64_be(1)).unwrap();
assert_eq!(
(key, value11),
@ -393,7 +393,7 @@ mod tests {
// Iterate with walk_dup
{
let tx = env.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_dup::<PlainStorageState>().unwrap();
let mut cursor = tx.cursor_dup_read::<PlainStorageState>().unwrap();
let first = cursor.first().unwrap().unwrap();
let mut walker = cursor.walk_dup(first.0, first.1.key).unwrap();
@ -408,7 +408,7 @@ mod tests {
// Iterate by using `walk`
{
let tx = env.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_dup::<PlainStorageState>().unwrap();
let mut cursor = tx.cursor_dup_read::<PlainStorageState>().unwrap();
let first = cursor.first().unwrap().unwrap();
let mut walker = cursor.walk(first.0).unwrap();
assert_eq!(Some(Ok((key1, value00))), walker.next());
@ -436,7 +436,7 @@ mod tests {
// Iterate with walk
{
let tx = env.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_dup::<PlainStorageState>().unwrap();
let mut cursor = tx.cursor_dup_read::<PlainStorageState>().unwrap();
let first = cursor.first().unwrap().unwrap();
let mut walker = cursor.walk(first.0).unwrap();
@ -449,7 +449,7 @@ mod tests {
// seek_by_key_subkey
{
let tx = env.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor_dup::<PlainStorageState>().unwrap();
let mut cursor = tx.cursor_dup_read::<PlainStorageState>().unwrap();
// NOTE: There are two values with same SubKey but only first one is shown
assert_eq!(Ok(Some(value00.clone())), cursor.seek_by_key_subkey(key1, value00.key));
@ -471,7 +471,7 @@ mod tests {
// Seek value with non existing key.
{
let tx = db.tx().expect(ERROR_INIT_TX);
let mut cursor = tx.cursor::<AccountHistory>().unwrap();
let mut cursor = tx.cursor_read::<AccountHistory>().unwrap();
// It will seek the one greater or equal to the query. Since we have `Address | 100`,
// `Address | 200` in the database and we're querying `Address | 150` it will return us

View File

@ -58,12 +58,12 @@ impl<'a, K: TransactionKind, E: EnvironmentKind> DbTxMutGAT<'a> for Tx<'_, K, E>
impl<'tx, K: TransactionKind, E: EnvironmentKind> DbTx<'tx> for Tx<'tx, K, E> {
// Iterate over read only values in database.
fn cursor<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, Error> {
fn cursor_read<T: Table>(&self) -> Result<<Self as DbTxGAT<'_>>::Cursor<T>, Error> {
self.new_cursor()
}
/// Iterate over read only values in database.
fn cursor_dup<T: DupSort>(&self) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, Error> {
fn cursor_dup_read<T: DupSort>(&self) -> Result<<Self as DbTxGAT<'_>>::DupCursor<T>, Error> {
self.new_cursor()
}
@ -120,11 +120,11 @@ impl<E: EnvironmentKind> DbTxMut<'_> for Tx<'_, RW, E> {
Ok(())
}
fn cursor_mut<T: Table>(&self) -> Result<<Self as DbTxMutGAT<'_>>::CursorMut<T>, Error> {
fn cursor_write<T: Table>(&self) -> Result<<Self as DbTxMutGAT<'_>>::CursorMut<T>, Error> {
self.new_cursor()
}
fn cursor_dup_mut<T: DupSort>(
fn cursor_dup_write<T: DupSort>(
&self,
) -> Result<<Self as DbTxMutGAT<'_>>::DupCursorMut<T>, Error> {
self.new_cursor()

View File

@ -213,7 +213,7 @@ table!(
/// // Is there any transaction after number 150 that changed this account?
/// {
/// let tx = db.tx().expect("");
/// let mut cursor = tx.cursor::<AccountHistory>().unwrap();
/// let mut cursor = tx.cursor_read::<AccountHistory>().unwrap();
/// // It will seek the one greater or equal to the query. Since we have `Address | 100`,
/// // `Address | 200` in the database and we're querying `Address | 150` it will return us

View File

@ -147,7 +147,7 @@ impl<'a, 'b, TX: DbTx<'a>> StateProvider for HistoricalStateProviderRef<'a, 'b,
return Ok(None)
}
let num = transaction_number.unwrap();
let mut cursor = self.tx.cursor_dup::<tables::StorageChangeSet>()?;
let mut cursor = self.tx.cursor_dup_read::<tables::StorageChangeSet>()?;
if let Some((_, entry)) = cursor.seek_exact((num, account).into())? {
if entry.key == storage_key {
@ -239,7 +239,7 @@ impl<'a, 'b, TX: DbTx<'a>> BlockHashProvider for LatestStateProviderRef<'a, 'b,
impl<'a, 'b, TX: DbTx<'a>> StateProvider for LatestStateProviderRef<'a, 'b, TX> {
/// Get storage.
fn storage(&self, account: Address, storage_key: StorageKey) -> Result<Option<StorageValue>> {
let mut cursor = self.db.cursor_dup::<tables::PlainStorageState>()?;
let mut cursor = self.db.cursor_dup_read::<tables::PlainStorageState>()?;
if let Some(entry) = cursor.seek_by_key_subkey(account, storage_key)? {
if entry.key == storage_key {
return Ok(Some(entry.value))