Decouple ASB/CLI Errors from Error sent over wire

What goes over the wire should not be coupled to the errors being printed.
For the CLI and ASB we introduce a separate error enum that is used for logging.
When sending over the wire the errors are mapped to and from the `network::spot_price::Error`.

As part of Bob-specific spot_price code was moved from the network into bob.
Clearly separation of the network API from bob/alice.
This commit is contained in:
Daniel Karzel 2021-05-05 13:04:55 +10:00
parent 52f648e1de
commit 5aac76598d
No known key found for this signature in database
GPG key ID: 30C3FC2E438ADB6E
9 changed files with 190 additions and 61 deletions

View file

@ -6,6 +6,7 @@ use crate::protocol::alice::{execution_setup, spot_price, State3};
use anyhow::{anyhow, Error};
use libp2p::request_response::{RequestId, ResponseChannel};
use libp2p::{NetworkBehaviour, PeerId};
use std::fmt::Debug;
use uuid::Uuid;
#[derive(Debug)]
@ -62,7 +63,10 @@ impl OutEvent {
#[derive(NetworkBehaviour)]
#[behaviour(out_event = "OutEvent", event_process = false)]
#[allow(missing_debug_implementations)]
pub struct Behaviour<LR: LatestRate + Send + 'static> {
pub struct Behaviour<LR>
where
LR: LatestRate + Send + 'static + Debug,
{
pub quote: quote::Behaviour,
pub spot_price: spot_price::Behaviour<LR>,
pub execution_setup: execution_setup::Behaviour,
@ -72,7 +76,7 @@ pub struct Behaviour<LR: LatestRate + Send + 'static> {
impl<LR> Behaviour<LR>
where
LR: LatestRate + Send + 'static,
LR: LatestRate + Send + 'static + Debug,
{
pub fn new(
balance: monero::Amount,