Skip to content

Commit 9c112fc

Browse files
author
Ivo Georgiev
authored
Merge pull request #175 from AdExNetwork/adapter-safety
follower: clone the adapter rather than drop
2 parents 29aa2ca + ac0104c commit 9c112fc

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

validator_worker/src/follower.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,13 @@ async fn on_new_state<'a, A: Adapter + 'static>(
6464
return Ok(on_error(&iface, &new_state, InvalidNewState::RootHash).await);
6565
}
6666

67-
let adapter = iface.adapter.read().await;
67+
let adapter = iface.adapter.read().await.clone();
6868

6969
if !adapter.verify(
7070
&iface.channel.spec.validators.leader().id,
7171
&proposed_state_root,
7272
&new_state.signature,
7373
)? {
74-
drop(adapter);
7574
return Ok(on_error(&iface, &new_state, InvalidNewState::Signature).await);
7675
}
7776

@@ -82,7 +81,6 @@ async fn on_new_state<'a, A: Adapter + 'static>(
8281
.map_or(Default::default(), |new_state| new_state.msg.balances);
8382

8483
if !is_valid_transition(&iface.channel, &prev_balances, &proposed_balances) {
85-
drop(adapter);
8684
return Ok(on_error(&iface, &new_state, InvalidNewState::Transition).await);
8785
}
8886

@@ -95,8 +93,6 @@ async fn on_new_state<'a, A: Adapter + 'static>(
9593
&health_threshold,
9694
);
9795

98-
drop(adapter);
99-
10096
iface
10197
.propagate(&[&MessageTypes::ApproveState(ApproveState {
10298
state_root: proposed_state_root,

0 commit comments

Comments
 (0)