mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
Decrease peer reputation on bad transactions (#4035)
* Decrease reputation on bad transactions * Don't punish on duplicate transactions
This commit is contained in:
committed by
Gavin Wood
parent
9515d34aee
commit
e73436d818
@@ -90,7 +90,9 @@ const UNEXPECTED_STATUS_REPUTATION_CHANGE: i32 = -(1 << 20);
|
||||
/// Reputation change when we are a light client and a peer is behind us.
|
||||
const PEER_BEHIND_US_LIGHT_REPUTATION_CHANGE: i32 = -(1 << 8);
|
||||
/// Reputation change when a peer sends us an extrinsic that we didn't know about.
|
||||
const NEW_EXTRINSIC_REPUTATION_CHANGE: i32 = 1 << 7;
|
||||
const GOOD_EXTRINSIC_REPUTATION_CHANGE: i32 = 1 << 7;
|
||||
/// Reputation change when a peer sends us a bad extrinsic.
|
||||
const BAD_EXTRINSIC_REPUTATION_CHANGE: i32 = -(1 << 12);
|
||||
/// We sent an RPC query to the given node, but it failed.
|
||||
const RPC_FAILED_REPUTATION_CHANGE: i32 = -(1 << 12);
|
||||
/// We received a message that failed to decode.
|
||||
@@ -1019,7 +1021,8 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
self.transaction_pool.import(
|
||||
self.peerset_handle.clone().into(),
|
||||
who.clone(),
|
||||
NEW_EXTRINSIC_REPUTATION_CHANGE,
|
||||
GOOD_EXTRINSIC_REPUTATION_CHANGE,
|
||||
BAD_EXTRINSIC_REPUTATION_CHANGE,
|
||||
t,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ pub trait TransactionPool<H: ExHashT, B: BlockT>: Send + Sync {
|
||||
&self,
|
||||
report_handle: ReportHandle,
|
||||
who: PeerId,
|
||||
reputation_change: i32,
|
||||
reputation_change_good: i32,
|
||||
reputation_change_bad: i32,
|
||||
transaction: B::Extrinsic,
|
||||
);
|
||||
/// Notify the pool about transactions broadcast.
|
||||
|
||||
@@ -399,7 +399,14 @@ impl TransactionPool<Hash, Block> for EmptyTransactionPool {
|
||||
Hash::default()
|
||||
}
|
||||
|
||||
fn import(&self, _report_handle: ReportHandle, _who: PeerId, _rep_change: i32, _transaction: Extrinsic) {}
|
||||
fn import(
|
||||
&self,
|
||||
_report_handle: ReportHandle,
|
||||
_who: PeerId,
|
||||
_rep_change_good: i32,
|
||||
_rep_change_bad: i32,
|
||||
_transaction: Extrinsic
|
||||
) {}
|
||||
|
||||
fn on_broadcasted(&self, _: HashMap<Hash, Vec<String>>) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user