mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
* Make RelayStrategy::final_decision() sync Signed-off-by: Serban Iorga <serban@parity.io> * Move logic from RelayStrategy to RelayReference Signed-off-by: Serban Iorga <serban@parity.io> * Rename RelayStrategy::final_decision() Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
260dad5110
commit
682fafdf56
@@ -23,7 +23,7 @@ use crate::{
|
||||
message_lane_loop::{
|
||||
SourceClient as MessageLaneSourceClient, TargetClient as MessageLaneTargetClient,
|
||||
},
|
||||
relay_strategy::{RationalStrategy, RelayReference, RelayStrategy},
|
||||
relay_strategy::{RelayReference, RelayStrategy},
|
||||
};
|
||||
|
||||
/// The relayer doesn't care about rewards.
|
||||
@@ -40,13 +40,20 @@ impl RelayStrategy for AltruisticStrategy {
|
||||
&mut self,
|
||||
reference: &mut RelayReference<P, SourceClient, TargetClient>,
|
||||
) -> bool {
|
||||
// we don't care about costs and rewards, but we want to report unprofitable transactions
|
||||
// => let rational strategy fill required fields
|
||||
let _ = RationalStrategy.decide(reference).await;
|
||||
// We don't care about costs and rewards, but we want to report unprofitable transactions.
|
||||
if let Err(e) = reference.update_cost_and_reward().await {
|
||||
log::debug!(
|
||||
target: "bridge",
|
||||
"Failed to update transaction cost and reward: {:?}. \
|
||||
The `unprofitable_delivery_transactions` metric will be inaccurate",
|
||||
e,
|
||||
);
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
async fn final_decision<
|
||||
fn on_final_decision<
|
||||
P: MessageLane,
|
||||
SourceClient: MessageLaneSourceClient<P>,
|
||||
TargetClient: MessageLaneTargetClient<P>,
|
||||
@@ -55,10 +62,11 @@ impl RelayStrategy for AltruisticStrategy {
|
||||
reference: &RelayReference<P, SourceClient, TargetClient>,
|
||||
) {
|
||||
if let Some(ref metrics) = reference.metrics {
|
||||
if reference.total_cost > reference.total_reward {
|
||||
if !reference.is_profitable() {
|
||||
log::debug!(
|
||||
target: "bridge",
|
||||
"The relayer has submitted unprofitable {} -> {} message delivery trabsaction with {} messages: total cost = {:?}, total reward = {:?}",
|
||||
"The relayer has submitted unprofitable {} -> {} message delivery transaction \
|
||||
with {} messages: total cost = {:?}, total reward = {:?}",
|
||||
P::SOURCE_NAME,
|
||||
P::TARGET_NAME,
|
||||
reference.index + 1,
|
||||
|
||||
Reference in New Issue
Block a user