Skip to content

Commit 2aba7ff

Browse files
authored
feat(network): add data type derives required by downstream libs (#714)
* feat: add PartialEq and Eq instances on some tx submission data types * feat: add PartialEq / Eq instances on Conway transactions * feat: add PartialOrd/Ord instances to EraTxId * feat: add some Clone instances for Messages * feat: add some instances for chain sync data types
1 parent 7e8e0d5 commit 2aba7ff

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

pallas-network/src/miniprotocols/chainsync/protocol.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub enum State {
1818
}
1919

2020
/// A generic chain-sync message for either header or block content
21-
#[derive(Debug)]
21+
#[derive(Debug, Clone, PartialEq, Eq)]
2222
pub enum Message<C> {
2323
RequestNext,
2424
AwaitReply,
@@ -30,14 +30,14 @@ pub enum Message<C> {
3030
Done,
3131
}
3232

33-
#[derive(Debug)]
33+
#[derive(Debug, Clone, PartialEq, Eq)]
3434
pub struct HeaderContent {
3535
pub variant: u8,
3636
pub byron_prefix: Option<(u8, u64)>,
3737
pub cbor: Vec<u8>,
3838
}
3939

40-
#[derive(Debug)]
40+
#[derive(Debug, Clone, PartialEq, Eq)]
4141
pub struct BlockContent(pub Vec<u8>);
4242

4343
impl Deref for BlockContent {
@@ -54,5 +54,5 @@ impl From<BlockContent> for Vec<u8> {
5454
}
5555
}
5656

57-
#[derive(Debug)]
57+
#[derive(Debug, Clone, PartialEq, Eq)]
5858
pub struct SkippedContent;

pallas-network/src/miniprotocols/txsubmission/protocol.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ pub type TxCount = u16;
1919
pub type TxSizeInBytes = u32;
2020

2121
// The bytes of a txId, tagged with an era number
22-
#[derive(Debug, Clone)]
22+
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
2323
pub struct EraTxId(pub u16, pub Vec<u8>);
2424

2525
// The bytes of a transaction, with an era number and some raw CBOR
2626
#[derive(Debug, Clone, Eq, PartialEq)]
2727
pub struct EraTxBody(pub u16, pub Vec<u8>);
2828

29-
#[derive(Debug)]
29+
#[derive(Debug, Clone, PartialEq, Eq)]
3030
pub struct TxIdAndSize<TxID>(pub TxID, pub TxSizeInBytes);
3131

3232
#[derive(Error, Debug)]
@@ -50,7 +50,7 @@ pub enum Error {
5050
Plexer(multiplexer::Error),
5151
}
5252

53-
#[derive(Debug)]
53+
#[derive(Debug, Clone, PartialEq, Eq)]
5454
pub enum Message<TxId, TxBody> {
5555
Init,
5656
RequestTxIds(Blocking, TxCount, TxCount),

pallas-primitives/src/conway/model.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ pub struct Block<'b> {
708708
#[deprecated(since = "1.0.0-alpha", note = "use `Block` instead")]
709709
pub type MintedBlock<'b> = Block<'b>;
710710

711-
#[derive(Clone, Serialize, Deserialize, Encode, Decode, Debug)]
711+
#[derive(Clone, Serialize, Deserialize, Encode, Decode, Debug, PartialEq)]
712712
pub struct Tx<'b> {
713713
#[b(0)]
714714
pub transaction_body: KeepRaw<'b, TransactionBody<'b>>,
@@ -723,6 +723,8 @@ pub struct Tx<'b> {
723723
pub auxiliary_data: Nullable<KeepRaw<'b, AuxiliaryData>>,
724724
}
725725

726+
impl Eq for Tx<'_> {}
727+
726728
#[deprecated(since = "1.0.0-alpha", note = "use `Tx` instead")]
727729
pub type MintedTx<'b> = Tx<'b>;
728730

0 commit comments

Comments
 (0)