mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-02-09 03:18:44 -05:00
Set appropriate name to codec
This commit is contained in:
parent
a11e894b31
commit
5a5a1c05f7
@ -59,12 +59,12 @@ impl ProtocolName for EncryptedSignatureProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
pub struct OneShotCodec<P> {
|
pub struct CborCodec<P> {
|
||||||
phantom: PhantomData<P>,
|
phantom: PhantomData<P>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<P> RequestResponseCodec for OneShotCodec<P>
|
impl<P> RequestResponseCodec for CborCodec<P>
|
||||||
where
|
where
|
||||||
P: Send + Sync + Clone + ProtocolName,
|
P: Send + Sync + Clone + ProtocolName,
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
network::request_response::{
|
network::request_response::{
|
||||||
EncryptedSignatureProtocol, OneShotCodec, Request, Response, TIMEOUT,
|
CborCodec, EncryptedSignatureProtocol, Request, Response, TIMEOUT,
|
||||||
},
|
},
|
||||||
protocol::bob::EncryptedSignature,
|
protocol::bob::EncryptedSignature,
|
||||||
};
|
};
|
||||||
@ -30,7 +30,7 @@ pub enum OutEvent {
|
|||||||
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Behaviour {
|
pub struct Behaviour {
|
||||||
rr: RequestResponse<OneShotCodec<EncryptedSignatureProtocol>>,
|
rr: RequestResponse<CborCodec<EncryptedSignatureProtocol>>,
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
events: VecDeque<OutEvent>,
|
events: VecDeque<OutEvent>,
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ impl Behaviour {
|
|||||||
_: &mut Context<'_>,
|
_: &mut Context<'_>,
|
||||||
_: &mut impl PollParameters,
|
_: &mut impl PollParameters,
|
||||||
) -> Poll<
|
) -> Poll<
|
||||||
NetworkBehaviourAction<RequestProtocol<OneShotCodec<EncryptedSignatureProtocol>>, OutEvent>,
|
NetworkBehaviourAction<RequestProtocol<CborCodec<EncryptedSignatureProtocol>>, OutEvent>,
|
||||||
> {
|
> {
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
||||||
@ -59,7 +59,7 @@ impl Default for Behaviour {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
rr: RequestResponse::new(
|
rr: RequestResponse::new(
|
||||||
OneShotCodec::default(),
|
CborCodec::default(),
|
||||||
vec![(EncryptedSignatureProtocol, ProtocolSupport::Inbound)],
|
vec![(EncryptedSignatureProtocol, ProtocolSupport::Inbound)],
|
||||||
config,
|
config,
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
monero,
|
monero,
|
||||||
network::request_response::{OneShotCodec, Request, Response, Swap, TIMEOUT},
|
network::request_response::{CborCodec, Request, Response, Swap, TIMEOUT},
|
||||||
protocol::bob,
|
protocol::bob,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
@ -37,7 +37,7 @@ pub struct SwapResponse {
|
|||||||
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Behaviour {
|
pub struct Behaviour {
|
||||||
rr: RequestResponse<OneShotCodec<Swap>>,
|
rr: RequestResponse<CborCodec<Swap>>,
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
events: VecDeque<OutEvent>,
|
events: VecDeque<OutEvent>,
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ impl Behaviour {
|
|||||||
&mut self,
|
&mut self,
|
||||||
_: &mut Context<'_>,
|
_: &mut Context<'_>,
|
||||||
_: &mut impl PollParameters,
|
_: &mut impl PollParameters,
|
||||||
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<Swap>>, OutEvent>> {
|
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<Swap>>, OutEvent>> {
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ impl Default for Behaviour {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
rr: RequestResponse::new(
|
rr: RequestResponse::new(
|
||||||
OneShotCodec::default(),
|
CborCodec::default(),
|
||||||
vec![(Swap, ProtocolSupport::Inbound)],
|
vec![(Swap, ProtocolSupport::Inbound)],
|
||||||
config,
|
config,
|
||||||
),
|
),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
monero,
|
monero,
|
||||||
network::request_response::{OneShotCodec, Request, Response, TransferProofProtocol, TIMEOUT},
|
network::request_response::{CborCodec, Request, Response, TransferProofProtocol, TIMEOUT},
|
||||||
};
|
};
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
request_response::{
|
request_response::{
|
||||||
@ -34,7 +34,7 @@ pub enum OutEvent {
|
|||||||
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Behaviour {
|
pub struct Behaviour {
|
||||||
rr: RequestResponse<OneShotCodec<TransferProofProtocol>>,
|
rr: RequestResponse<CborCodec<TransferProofProtocol>>,
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
events: VecDeque<OutEvent>,
|
events: VecDeque<OutEvent>,
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ impl Behaviour {
|
|||||||
&mut self,
|
&mut self,
|
||||||
_: &mut Context<'_>,
|
_: &mut Context<'_>,
|
||||||
_: &mut impl PollParameters,
|
_: &mut impl PollParameters,
|
||||||
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<TransferProofProtocol>>, OutEvent>>
|
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<TransferProofProtocol>>, OutEvent>>
|
||||||
{
|
{
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
||||||
@ -67,7 +67,7 @@ impl Default for Behaviour {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
rr: RequestResponse::new(
|
rr: RequestResponse::new(
|
||||||
OneShotCodec::default(),
|
CborCodec::default(),
|
||||||
vec![(TransferProofProtocol, ProtocolSupport::Outbound)],
|
vec![(TransferProofProtocol, ProtocolSupport::Outbound)],
|
||||||
config,
|
config,
|
||||||
),
|
),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::network::request_response::{
|
use crate::network::request_response::{
|
||||||
EncryptedSignatureProtocol, OneShotCodec, Request, Response, TIMEOUT,
|
CborCodec, EncryptedSignatureProtocol, Request, Response, TIMEOUT,
|
||||||
};
|
};
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
request_response::{
|
request_response::{
|
||||||
@ -32,7 +32,7 @@ pub enum OutEvent {
|
|||||||
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Behaviour {
|
pub struct Behaviour {
|
||||||
rr: RequestResponse<OneShotCodec<EncryptedSignatureProtocol>>,
|
rr: RequestResponse<CborCodec<EncryptedSignatureProtocol>>,
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
events: VecDeque<OutEvent>,
|
events: VecDeque<OutEvent>,
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ impl Behaviour {
|
|||||||
_: &mut Context<'_>,
|
_: &mut Context<'_>,
|
||||||
_: &mut impl PollParameters,
|
_: &mut impl PollParameters,
|
||||||
) -> Poll<
|
) -> Poll<
|
||||||
NetworkBehaviourAction<RequestProtocol<OneShotCodec<EncryptedSignatureProtocol>>, OutEvent>,
|
NetworkBehaviourAction<RequestProtocol<CborCodec<EncryptedSignatureProtocol>>, OutEvent>,
|
||||||
> {
|
> {
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
||||||
@ -66,7 +66,7 @@ impl Default for Behaviour {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
rr: RequestResponse::new(
|
rr: RequestResponse::new(
|
||||||
OneShotCodec::default(),
|
CborCodec::default(),
|
||||||
vec![(EncryptedSignatureProtocol, ProtocolSupport::Outbound)],
|
vec![(EncryptedSignatureProtocol, ProtocolSupport::Outbound)],
|
||||||
config,
|
config,
|
||||||
),
|
),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
network::request_response::{OneShotCodec, Request, Response, Swap, TIMEOUT},
|
network::request_response::{CborCodec, Request, Response, Swap, TIMEOUT},
|
||||||
protocol::alice::SwapResponse,
|
protocol::alice::SwapResponse,
|
||||||
};
|
};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
@ -35,7 +35,7 @@ pub struct OutEvent {
|
|||||||
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Behaviour {
|
pub struct Behaviour {
|
||||||
rr: RequestResponse<OneShotCodec<Swap>>,
|
rr: RequestResponse<CborCodec<Swap>>,
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
events: VecDeque<OutEvent>,
|
events: VecDeque<OutEvent>,
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ impl Behaviour {
|
|||||||
&mut self,
|
&mut self,
|
||||||
_: &mut Context<'_>,
|
_: &mut Context<'_>,
|
||||||
_: &mut impl PollParameters,
|
_: &mut impl PollParameters,
|
||||||
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<Swap>>, OutEvent>> {
|
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<Swap>>, OutEvent>> {
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ impl Default for Behaviour {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
rr: RequestResponse::new(
|
rr: RequestResponse::new(
|
||||||
OneShotCodec::default(),
|
CborCodec::default(),
|
||||||
vec![(Swap, ProtocolSupport::Outbound)],
|
vec![(Swap, ProtocolSupport::Outbound)],
|
||||||
config,
|
config,
|
||||||
),
|
),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
network::request_response::{OneShotCodec, Request, Response, TransferProofProtocol, TIMEOUT},
|
network::request_response::{CborCodec, Request, Response, TransferProofProtocol, TIMEOUT},
|
||||||
protocol::alice::TransferProof,
|
protocol::alice::TransferProof,
|
||||||
};
|
};
|
||||||
use libp2p::{
|
use libp2p::{
|
||||||
@ -28,7 +28,7 @@ pub enum OutEvent {
|
|||||||
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
|
||||||
#[allow(missing_debug_implementations)]
|
#[allow(missing_debug_implementations)]
|
||||||
pub struct Behaviour {
|
pub struct Behaviour {
|
||||||
rr: RequestResponse<OneShotCodec<TransferProofProtocol>>,
|
rr: RequestResponse<CborCodec<TransferProofProtocol>>,
|
||||||
#[behaviour(ignore)]
|
#[behaviour(ignore)]
|
||||||
events: VecDeque<OutEvent>,
|
events: VecDeque<OutEvent>,
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ impl Behaviour {
|
|||||||
&mut self,
|
&mut self,
|
||||||
_: &mut Context<'_>,
|
_: &mut Context<'_>,
|
||||||
_: &mut impl PollParameters,
|
_: &mut impl PollParameters,
|
||||||
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<TransferProofProtocol>>, OutEvent>>
|
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<TransferProofProtocol>>, OutEvent>>
|
||||||
{
|
{
|
||||||
if let Some(event) = self.events.pop_front() {
|
if let Some(event) = self.events.pop_front() {
|
||||||
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
|
||||||
@ -56,7 +56,7 @@ impl Default for Behaviour {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
rr: RequestResponse::new(
|
rr: RequestResponse::new(
|
||||||
OneShotCodec::default(),
|
CborCodec::default(),
|
||||||
vec![(TransferProofProtocol, ProtocolSupport::Inbound)],
|
vec![(TransferProofProtocol, ProtocolSupport::Inbound)],
|
||||||
config,
|
config,
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user