fix(net): outgoing requsts (#398)

* remove inpossible case

* fix(net): outgoing requests stopping
This commit is contained in:
Will Smith
2022-12-13 02:25:41 -05:00
committed by GitHub
parent d2acc6bdff
commit 6aa2daee0f
7 changed files with 14 additions and 11 deletions

View File

@ -532,10 +532,9 @@ where
?error,
"Outgoing pending session failed"
);
this.swarm
.state_mut()
.peers_mut()
.apply_reputation_change(&peer_id, ReputationChangeKind::FailedToConnect);
let swarm = this.swarm.state_mut().peers_mut();
swarm.on_closed_outgoing_pending_session();
swarm.apply_reputation_change(&peer_id, ReputationChangeKind::FailedToConnect);
}
SwarmEvent::OutgoingConnectionError { remote_addr, peer_id, error } => {
warn!(

View File

@ -121,6 +121,10 @@ impl PeersManager {
pub(crate) fn on_closed_incoming_pending_session(&mut self) {
self.connection_info.decr_in()
}
/// Invoked when a pending session was closed.
pub(crate) fn on_closed_outgoing_pending_session(&mut self) {
self.connection_info.decr_out()
}
/// Called when a new _incoming_ active session was established to the given peer.
///

View File

@ -194,7 +194,7 @@ where
) -> PoolResult<TxHash> {
match tx {
TransactionValidationOutcome::Valid { balance, state_nonce, transaction } => {
let sender_id = self.get_sender_id(*transaction.sender());
let sender_id = self.get_sender_id(transaction.sender());
let transaction_id = TransactionId::new(sender_id, transaction.nonce());
let tx = ValidPoolTransaction {

View File

@ -238,7 +238,7 @@ impl<T: TransactionOrdering> TxPool<T> {
Err(PoolError::ProtocolFeeCapTooLow(*transaction.hash(), fee_cap))
}
Err(InsertErr::ExceededSenderTransactionsCapacity { transaction }) => {
Err(PoolError::SpammerExceededCapacity(*transaction.sender(), *transaction.hash()))
Err(PoolError::SpammerExceededCapacity(transaction.sender(), *transaction.hash()))
}
}
}

View File

@ -282,10 +282,10 @@ impl PoolTransaction for MockTransaction {
}
}
fn sender(&self) -> &Address {
fn sender(&self) -> Address {
match self {
MockTransaction::Legacy { sender, .. } => sender,
MockTransaction::Eip1559 { sender, .. } => sender,
MockTransaction::Legacy { sender, .. } => *sender,
MockTransaction::Eip1559 { sender, .. } => *sender,
}
}

View File

@ -240,7 +240,7 @@ pub trait PoolTransaction: fmt::Debug + Send + Sync + FromRecoveredTransaction {
fn hash(&self) -> &TxHash;
/// The Sender of the transaction.
fn sender(&self) -> &Address;
fn sender(&self) -> Address;
/// Returns the nonce for this transaction.
fn nonce(&self) -> u64;

View File

@ -69,7 +69,7 @@ impl<T: PoolTransaction> ValidPoolTransaction<T> {
}
/// Returns the address of the sender
pub fn sender(&self) -> &Address {
pub fn sender(&self) -> Address {
self.transaction.sender()
}