Skip to content

Commit 391a3fa

Browse files
authored
Merge pull request #476 from filecoin-project/chore/rename-consume
Refactor consume/take
2 parents bca2478 + b3f6326 commit 391a3fa

File tree

13 files changed

+25
-25
lines changed

13 files changed

+25
-25
lines changed

fvm/src/blockstore/buffered.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333
}
3434
}
3535

36-
pub fn consume(self) -> BS {
36+
pub fn into_inner(self) -> BS {
3737
self.base
3838
}
3939
}

fvm/src/call_manager/default.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{account_actor, syscall_error};
1919

2020
/// The default [`CallManager`] implementation.
2121
#[repr(transparent)]
22-
pub struct DefaultCallManager<M>(Option<InnerDefaultCallManager<M>>);
22+
pub struct DefaultCallManager<M>(Option<Box<InnerDefaultCallManager<M>>>);
2323

2424
#[doc(hidden)]
2525
#[derive(Deref, DerefMut)]
@@ -65,15 +65,15 @@ where
6565
type Machine = M;
6666

6767
fn new(machine: M, gas_limit: i64, origin: Address, nonce: u64) -> Self {
68-
DefaultCallManager(Some(InnerDefaultCallManager {
68+
DefaultCallManager(Some(Box::new(InnerDefaultCallManager {
6969
machine,
7070
gas_tracker: GasTracker::new(gas_limit, 0),
7171
origin,
7272
nonce,
7373
num_actors_created: 0,
7474
call_stack_depth: 0,
7575
backtrace: Backtrace::default(),
76-
}))
76+
})))
7777
}
7878

7979
fn send<K>(
@@ -288,7 +288,7 @@ where
288288
match kernel.block_create(DAG_CBOR, params) {
289289
Ok(id) => id,
290290
// This could fail if we pass some global memory limit.
291-
Err(err) => return (Err(err), kernel.take()),
291+
Err(err) => return (Err(err), kernel.into_call_manager()),
292292
}
293293
} else {
294294
super::NO_DATA_BLOCK_ID
@@ -316,7 +316,7 @@ where
316316
.or_fatal()
317317
{
318318
Ok(ret) => ret,
319-
Err(err) => return (Err(err), store.into_data().kernel.take()),
319+
Err(err) => return (Err(err), store.into_data().kernel.into_call_manager()),
320320
};
321321

322322
// From this point on, there are no more syscall errors, only aborts.
@@ -366,7 +366,7 @@ where
366366

367367
let invocation_data = store.into_data();
368368
let last_error = invocation_data.last_error;
369-
let mut cm = invocation_data.kernel.take();
369+
let mut cm = invocation_data.kernel.into_call_manager();
370370

371371
// Process the result, updating the backtrace if necessary.
372372
let ret = match result {

fvm/src/executor/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ where
181181

182182
/// Consume consumes the executor and returns the Machine. If the Machine had
183183
/// been poisoned during execution, the Option will be None.
184-
pub fn consume(self) -> Option<<K::CallManager as CallManager>::Machine> {
184+
pub fn into_machine(self) -> Option<<K::CallManager as CallManager>::Machine> {
185185
self.0
186186
}
187187

fvm/src/kernel/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ where
7676
{
7777
type CallManager = C;
7878

79-
fn take(self) -> Self::CallManager
79+
fn into_call_manager(self) -> Self::CallManager
8080
where
8181
Self: Sized,
8282
{

fvm/src/kernel/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub trait Kernel:
4646
type CallManager: CallManager;
4747

4848
/// Consume the [`Kernel`] and return the underlying [`CallManager`].
49-
fn take(self) -> Self::CallManager
49+
fn into_call_manager(self) -> Self::CallManager
5050
where
5151
Self: Sized;
5252

fvm/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ mod test {
9696
let mut bs = MemoryBlockstore::default();
9797
let mut st = StateTree::new(bs, StateTreeVersion::V4).unwrap();
9898
let root = st.flush().unwrap();
99-
bs = st.consume();
99+
bs = st.into_store();
100100

101101
// An empty built-in actors manifest.
102102
let manifest_cid = {

fvm/src/machine/boxed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ impl<M: Machine> Machine for Box<M> {
6060
}
6161

6262
#[inline(always)]
63-
fn consume(self) -> Self::Blockstore {
64-
(*self).consume()
63+
fn into_store(self) -> Self::Blockstore {
64+
(*self).into_store()
6565
}
6666

6767
#[inline(always)]

fvm/src/machine/default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ where
272272
Ok(())
273273
}
274274

275-
fn consume(self) -> Self::Blockstore {
276-
self.state_tree.consume()
275+
fn into_store(self) -> Self::Blockstore {
276+
self.state_tree.into_store()
277277
}
278278
}

fvm/src/machine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub trait Machine: 'static {
8383
}
8484

8585
/// Consumes the machine and returns the owned blockstore.
86-
fn consume(self) -> Self::Blockstore;
86+
fn into_store(self) -> Self::Blockstore;
8787
}
8888

8989
/// Network-level settings. Except when testing locally, changing any of these likely requires a

fvm/src/state_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ where
496496
}
497497

498498
/// Consumes this StateTree and returns the Blockstore it owns via the HAMT.
499-
pub fn consume(self) -> S {
500-
self.hamt.consume()
499+
pub fn into_store(self) -> S {
500+
self.hamt.into_store()
501501
}
502502

503503
pub fn for_each<F>(&self, mut f: F) -> anyhow::Result<()>

0 commit comments

Comments
 (0)