You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.2 KiB
47 lines
1.2 KiB
use crate::monero;
|
|
use crate::network::cbor_request_response::CborCodec;
|
|
use libp2p::core::ProtocolName;
|
|
use libp2p::request_response::{
|
|
ProtocolSupport, RequestResponse, RequestResponseConfig, RequestResponseEvent,
|
|
RequestResponseMessage,
|
|
};
|
|
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
pub type OutEvent = RequestResponseEvent<Request, ()>;
|
|
|
|
#[derive(Debug, Clone, Copy, Default)]
|
|
pub struct TransferProofProtocol;
|
|
|
|
impl ProtocolName for TransferProofProtocol {
|
|
fn protocol_name(&self) -> &[u8] {
|
|
b"/comit/xmr/btc/transfer_proof/1.0.0"
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
|
pub struct Request {
|
|
pub swap_id: Uuid,
|
|
pub tx_lock_proof: monero::TransferProof,
|
|
}
|
|
|
|
pub type Behaviour = RequestResponse<CborCodec<TransferProofProtocol, Request, ()>>;
|
|
|
|
pub type Message = RequestResponseMessage<Request, ()>;
|
|
|
|
pub fn alice() -> Behaviour {
|
|
Behaviour::new(
|
|
CborCodec::default(),
|
|
vec![(TransferProofProtocol, ProtocolSupport::Outbound)],
|
|
RequestResponseConfig::default(),
|
|
)
|
|
}
|
|
|
|
pub fn bob() -> Behaviour {
|
|
Behaviour::new(
|
|
CborCodec::default(),
|
|
vec![(TransferProofProtocol, ProtocolSupport::Inbound)],
|
|
RequestResponseConfig::default(),
|
|
)
|
|
}
|