Skip to content

Commit 78f59bb

Browse files
committed
fix(transaction_pool/candidates): candidate not added if we have received same candidate from another peer
1 parent 453b283 commit 78f59bb

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

node/src/transaction_pool/candidate/transaction_pool_candidate_actions.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ pub enum TransactionPoolCandidateAction {
6060
impl redux::EnablingCondition<crate::State> for TransactionPoolCandidateAction {
6161
fn is_enabled(&self, state: &crate::State, _time: redux::Timestamp) -> bool {
6262
match self {
63-
TransactionPoolCandidateAction::InfoReceived { info, .. } => {
63+
TransactionPoolCandidateAction::InfoReceived { peer_id, info } => {
6464
!state.transaction_pool.contains(&info.hash)
65-
&& !state.transaction_pool.candidates.contains(&info.hash)
65+
&& !state
66+
.transaction_pool
67+
.candidates
68+
.peer_contains(*peer_id, &info.hash)
6669
}
6770
TransactionPoolCandidateAction::FetchAll => state.p2p.ready().is_some(),
6871
TransactionPoolCandidateAction::FetchInit { peer_id, hash } => {

node/src/transaction_pool/candidate/transaction_pool_candidate_state.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ impl TransactionPoolCandidatesState {
6868
self.by_hash.contains_key(hash)
6969
}
7070

71+
pub fn peer_contains(&self, peer_id: PeerId, hash: &TransactionHash) -> bool {
72+
self.by_peer
73+
.get(&peer_id)
74+
.map_or(false, |txs| txs.contains_key(hash))
75+
}
76+
7177
pub fn get(
7278
&self,
7379
peer_id: PeerId,

node/src/transaction_pool/transaction_pool_reducer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl TransactionPoolState {
249249
(rpc_action, accepted, rejected)
250250
}
251251
Err(e) => {
252-
bug_condition!("unsafe_apply error: {:?}", e);
252+
crate::core::warn!(meta.time(); kind = "TransactionPoolUnsafeApplyError", summary = e);
253253
return;
254254
}
255255
};

0 commit comments

Comments
 (0)