Set appropriate name to codec

This commit is contained in:
Franck Royer 2021-02-05 13:25:34 +11:00
parent a11e894b31
commit 5a5a1c05f7
No known key found for this signature in database
GPG Key ID: A82ED75A8DFC50A4
7 changed files with 26 additions and 26 deletions

View File

@ -59,12 +59,12 @@ impl ProtocolName for EncryptedSignatureProtocol {
}
#[derive(Clone, Copy, Debug, Default)]
pub struct OneShotCodec<P> {
pub struct CborCodec<P> {
phantom: PhantomData<P>,
}
#[async_trait]
impl<P> RequestResponseCodec for OneShotCodec<P>
impl<P> RequestResponseCodec for CborCodec<P>
where
P: Send + Sync + Clone + ProtocolName,
{

View File

@ -1,6 +1,6 @@
use crate::{
network::request_response::{
EncryptedSignatureProtocol, OneShotCodec, Request, Response, TIMEOUT,
CborCodec, EncryptedSignatureProtocol, Request, Response, TIMEOUT,
},
protocol::bob::EncryptedSignature,
};
@ -30,7 +30,7 @@ pub enum OutEvent {
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
#[allow(missing_debug_implementations)]
pub struct Behaviour {
rr: RequestResponse<OneShotCodec<EncryptedSignatureProtocol>>,
rr: RequestResponse<CborCodec<EncryptedSignatureProtocol>>,
#[behaviour(ignore)]
events: VecDeque<OutEvent>,
}
@ -41,7 +41,7 @@ impl Behaviour {
_: &mut Context<'_>,
_: &mut impl PollParameters,
) -> Poll<
NetworkBehaviourAction<RequestProtocol<OneShotCodec<EncryptedSignatureProtocol>>, OutEvent>,
NetworkBehaviourAction<RequestProtocol<CborCodec<EncryptedSignatureProtocol>>, OutEvent>,
> {
if let Some(event) = self.events.pop_front() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
@ -59,7 +59,7 @@ impl Default for Behaviour {
Self {
rr: RequestResponse::new(
OneShotCodec::default(),
CborCodec::default(),
vec![(EncryptedSignatureProtocol, ProtocolSupport::Inbound)],
config,
),

View File

@ -1,6 +1,6 @@
use crate::{
monero,
network::request_response::{OneShotCodec, Request, Response, Swap, TIMEOUT},
network::request_response::{CborCodec, Request, Response, Swap, TIMEOUT},
protocol::bob,
};
use anyhow::{anyhow, Result};
@ -37,7 +37,7 @@ pub struct SwapResponse {
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
#[allow(missing_debug_implementations)]
pub struct Behaviour {
rr: RequestResponse<OneShotCodec<Swap>>,
rr: RequestResponse<CborCodec<Swap>>,
#[behaviour(ignore)]
events: VecDeque<OutEvent>,
}
@ -55,7 +55,7 @@ impl Behaviour {
&mut self,
_: &mut Context<'_>,
_: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<Swap>>, OutEvent>> {
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<Swap>>, OutEvent>> {
if let Some(event) = self.events.pop_front() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
}
@ -73,7 +73,7 @@ impl Default for Behaviour {
Self {
rr: RequestResponse::new(
OneShotCodec::default(),
CborCodec::default(),
vec![(Swap, ProtocolSupport::Inbound)],
config,
),

View File

@ -1,6 +1,6 @@
use crate::{
monero,
network::request_response::{OneShotCodec, Request, Response, TransferProofProtocol, TIMEOUT},
network::request_response::{CborCodec, Request, Response, TransferProofProtocol, TIMEOUT},
};
use libp2p::{
request_response::{
@ -34,7 +34,7 @@ pub enum OutEvent {
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
#[allow(missing_debug_implementations)]
pub struct Behaviour {
rr: RequestResponse<OneShotCodec<TransferProofProtocol>>,
rr: RequestResponse<CborCodec<TransferProofProtocol>>,
#[behaviour(ignore)]
events: VecDeque<OutEvent>,
}
@ -49,7 +49,7 @@ impl Behaviour {
&mut self,
_: &mut Context<'_>,
_: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<TransferProofProtocol>>, OutEvent>>
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<TransferProofProtocol>>, OutEvent>>
{
if let Some(event) = self.events.pop_front() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
@ -67,7 +67,7 @@ impl Default for Behaviour {
Self {
rr: RequestResponse::new(
OneShotCodec::default(),
CborCodec::default(),
vec![(TransferProofProtocol, ProtocolSupport::Outbound)],
config,
),

View File

@ -1,5 +1,5 @@
use crate::network::request_response::{
EncryptedSignatureProtocol, OneShotCodec, Request, Response, TIMEOUT,
CborCodec, EncryptedSignatureProtocol, Request, Response, TIMEOUT,
};
use libp2p::{
request_response::{
@ -32,7 +32,7 @@ pub enum OutEvent {
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
#[allow(missing_debug_implementations)]
pub struct Behaviour {
rr: RequestResponse<OneShotCodec<EncryptedSignatureProtocol>>,
rr: RequestResponse<CborCodec<EncryptedSignatureProtocol>>,
#[behaviour(ignore)]
events: VecDeque<OutEvent>,
}
@ -48,7 +48,7 @@ impl Behaviour {
_: &mut Context<'_>,
_: &mut impl PollParameters,
) -> Poll<
NetworkBehaviourAction<RequestProtocol<OneShotCodec<EncryptedSignatureProtocol>>, OutEvent>,
NetworkBehaviourAction<RequestProtocol<CborCodec<EncryptedSignatureProtocol>>, OutEvent>,
> {
if let Some(event) = self.events.pop_front() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
@ -66,7 +66,7 @@ impl Default for Behaviour {
Self {
rr: RequestResponse::new(
OneShotCodec::default(),
CborCodec::default(),
vec![(EncryptedSignatureProtocol, ProtocolSupport::Outbound)],
config,
),

View File

@ -1,5 +1,5 @@
use crate::{
network::request_response::{OneShotCodec, Request, Response, Swap, TIMEOUT},
network::request_response::{CborCodec, Request, Response, Swap, TIMEOUT},
protocol::alice::SwapResponse,
};
use anyhow::Result;
@ -35,7 +35,7 @@ pub struct OutEvent {
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
#[allow(missing_debug_implementations)]
pub struct Behaviour {
rr: RequestResponse<OneShotCodec<Swap>>,
rr: RequestResponse<CborCodec<Swap>>,
#[behaviour(ignore)]
events: VecDeque<OutEvent>,
}
@ -52,7 +52,7 @@ impl Behaviour {
&mut self,
_: &mut Context<'_>,
_: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<Swap>>, OutEvent>> {
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<Swap>>, OutEvent>> {
if let Some(event) = self.events.pop_front() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
}
@ -70,7 +70,7 @@ impl Default for Behaviour {
Self {
rr: RequestResponse::new(
OneShotCodec::default(),
CborCodec::default(),
vec![(Swap, ProtocolSupport::Outbound)],
config,
),

View File

@ -1,5 +1,5 @@
use crate::{
network::request_response::{OneShotCodec, Request, Response, TransferProofProtocol, TIMEOUT},
network::request_response::{CborCodec, Request, Response, TransferProofProtocol, TIMEOUT},
protocol::alice::TransferProof,
};
use libp2p::{
@ -28,7 +28,7 @@ pub enum OutEvent {
#[behaviour(out_event = "OutEvent", poll_method = "poll")]
#[allow(missing_debug_implementations)]
pub struct Behaviour {
rr: RequestResponse<OneShotCodec<TransferProofProtocol>>,
rr: RequestResponse<CborCodec<TransferProofProtocol>>,
#[behaviour(ignore)]
events: VecDeque<OutEvent>,
}
@ -38,7 +38,7 @@ impl Behaviour {
&mut self,
_: &mut Context<'_>,
_: &mut impl PollParameters,
) -> Poll<NetworkBehaviourAction<RequestProtocol<OneShotCodec<TransferProofProtocol>>, OutEvent>>
) -> Poll<NetworkBehaviourAction<RequestProtocol<CborCodec<TransferProofProtocol>>, OutEvent>>
{
if let Some(event) = self.events.pop_front() {
return Poll::Ready(NetworkBehaviourAction::GenerateEvent(event));
@ -56,7 +56,7 @@ impl Default for Behaviour {
Self {
rr: RequestResponse::new(
OneShotCodec::default(),
CborCodec::default(),
vec![(TransferProofProtocol, ProtocolSupport::Inbound)],
config,
),