@@ -72,8 +72,8 @@ pub struct VM<N: Network, C: ConsensusStorage<N>> {
72
72
process : Arc < RwLock < Process < N > > > ,
73
73
/// The VM store.
74
74
store : ConsensusStore < N , C > ,
75
- /// The lock for advancing blocks .
76
- block_lock : Arc < Mutex < ( ) > > ,
75
+ /// The lock to guarantee atomicity over calls to speculate and finalize .
76
+ atomic_lock : Arc < Mutex < ( ) > > ,
77
77
}
78
78
79
79
impl < N : Network , C : ConsensusStorage < N > > VM < N , C > {
@@ -171,7 +171,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
171
171
}
172
172
173
173
// Return the new VM.
174
- Ok ( Self { process : Arc :: new ( RwLock :: new ( process) ) , store, block_lock : Arc :: new ( Mutex :: new ( ( ) ) ) } )
174
+ Ok ( Self { process : Arc :: new ( RwLock :: new ( process) ) , store, atomic_lock : Arc :: new ( Mutex :: new ( ( ) ) ) } )
175
175
}
176
176
177
177
/// Returns `true` if a program with the given program ID exists.
@@ -312,10 +312,6 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
312
312
/// Adds the given block into the VM.
313
313
#[ inline]
314
314
pub fn add_next_block ( & self , block : & Block < N > ) -> Result < ( ) > {
315
- // Acquire the block lock, which is needed to ensure this function is not called concurrently.
316
- // Note: This lock must be held for the entire scope of this function.
317
- let _block_lock = self . block_lock . lock ( ) ;
318
-
319
315
// Construct the finalize state.
320
316
let state = FinalizeGlobalState :: new :: < N > (
321
317
block. round ( ) ,
0 commit comments