Skip to content

Commit 747c725

Browse files
authored
fix: Unswap block overrides methods (#88)
* fix: why were these swapped? * chore: bump version
1 parent 121563a commit 747c725

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "trevm"
3-
version = "0.19.10"
3+
version = "0.19.11"
44
rust-version = "1.83.0"
55
edition = "2021"
66
authors = ["init4"]

src/evm.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -1436,18 +1436,15 @@ impl<'a, Ext, Db: Database, TrevmState: HasTx> Trevm<'a, Ext, Db, TrevmState> {
14361436
// -- NEEDS TX with State<Db>
14371437

14381438
impl<Ext, Db: Database + StateAcc> EvmNeedsTx<'_, Ext, Db> {
1439-
/// Apply block overrides to the current block. This function is
1440-
/// intended to be used by shared states, where mutable access may fail, e.
1441-
/// g. an `Arc<Db>`. Prefer [`Self::try_apply_block_overrides`] when
1442-
/// available.
1439+
/// Apply block overrides to the current block.
14431440
///
14441441
/// Note that this is NOT reversible. The overrides are applied directly to
14451442
/// the underlying state and these changes cannot be removed. If it is
14461443
/// important that you have access to the pre-change state, you should wrap
14471444
/// the existing DB in a new [`State`] and apply the overrides to that.
14481445
///
14491446
/// [`State`]: revm::db::State
1450-
pub fn try_apply_block_overrides(mut self, overrides: &BlockOverrides) -> Self {
1447+
pub fn apply_block_overrides(mut self, overrides: &BlockOverrides) -> Self {
14511448
overrides.fill_block(&mut self.inner);
14521449

14531450
if let Some(hashes) = overrides.block_hash.as_ref() {
@@ -1457,36 +1454,36 @@ impl<Ext, Db: Database + StateAcc> EvmNeedsTx<'_, Ext, Db> {
14571454
self
14581455
}
14591456

1460-
/// Apply block overrides to the current block, if they are provided. This
1461-
/// function is intended to be used by shared states, where mutable access
1462-
/// may fail, e.g. an `Arc<Db>`.Prefer
1463-
/// [`Self::try_maybe_apply_block_overrides`] when available.
1457+
/// Apply block overrides to the current block, if they are provided.
14641458
///
14651459
/// Note that this is NOT reversible. The overrides are applied directly to
14661460
/// the underlying state and these changes cannot be removed. If it is
14671461
/// important that you have access to the pre-change state, you should wrap
14681462
/// the existing DB in a new [`State`] and apply the overrides to that.
14691463
///
14701464
/// [`State`]: revm::db::State
1471-
pub fn try_maybe_apply_block_overrides(self, overrides: Option<&BlockOverrides>) -> Self {
1465+
pub fn maybe_apply_block_overrides(self, overrides: Option<&BlockOverrides>) -> Self {
14721466
if let Some(overrides) = overrides {
1473-
self.try_apply_block_overrides(overrides)
1467+
self.apply_block_overrides(overrides)
14741468
} else {
14751469
self
14761470
}
14771471
}
14781472
}
14791473

14801474
impl<'a, Ext, Db: Database + TryStateAcc> EvmNeedsTx<'a, Ext, Db> {
1481-
/// Apply block overrides to the current block.
1475+
/// Apply block overrides to the current block. This function is
1476+
/// intended to be used by shared states, where mutable access may fail, e.
1477+
/// g. an `Arc<Db>`. Prefer [`Self::apply_block_overrides`] when
1478+
/// available.
14821479
///
14831480
/// Note that this is NOT reversible. The overrides are applied directly to
14841481
/// the underlying state and these changes cannot be removed. If it is
14851482
/// important that you have access to the pre-change state, you should wrap
14861483
/// the existing DB in a new [`State`] and apply the overrides to that.
14871484
///
14881485
/// [`State`]: revm::db::State
1489-
pub fn apply_block_overrides(
1486+
pub fn try_apply_block_overrides(
14901487
mut self,
14911488
overrides: &BlockOverrides,
14921489
) -> Result<Self, EvmErrored<'a, Ext, Db, <Db as TryStateAcc>::Error>> {
@@ -1499,20 +1496,23 @@ impl<'a, Ext, Db: Database + TryStateAcc> EvmNeedsTx<'a, Ext, Db> {
14991496
Ok(self)
15001497
}
15011498

1502-
/// Apply block overrides to the current block, if they are provided.
1499+
/// Apply block overrides to the current block, if they are provided. This
1500+
/// function is intended to be used by shared states, where mutable access
1501+
/// may fail, e.g. an `Arc<Db>`.Prefer
1502+
/// [`Self::maybe_apply_block_overrides`] when available.
15031503
///
15041504
/// Note that this is NOT reversible. The overrides are applied directly to
15051505
/// the underlying state and these changes cannot be removed. If it is
15061506
/// important that you have access to the pre-change state, you should wrap
15071507
/// the existing DB in a new [`State`] and apply the overrides to that.
15081508
///
15091509
/// [`State`]: revm::db::State
1510-
pub fn maybe_apply_block_overrides(
1510+
pub fn try_maybe_apply_block_overrides(
15111511
self,
15121512
overrides: Option<&BlockOverrides>,
15131513
) -> Result<Self, EvmErrored<'a, Ext, Db, <Db as TryStateAcc>::Error>> {
15141514
if let Some(overrides) = overrides {
1515-
self.apply_block_overrides(overrides)
1515+
self.try_apply_block_overrides(overrides)
15161516
} else {
15171517
Ok(self)
15181518
}

0 commit comments

Comments
 (0)