|
25 | 25 | use crate::api::{ETH_PROTOCOL, WARP_SYNC_PROTOCOL_ID}; |
26 | 26 | use self::SyncPacket::*; |
27 | 27 |
|
28 | | -use enum_primitive::{enum_from_primitive, enum_from_primitive_impl, enum_from_primitive_impl_ty}; |
| 28 | +use enum_primitive_derive::Primitive; |
29 | 29 | use network::{PacketId, ProtocolId}; |
30 | 30 |
|
31 | | -enum_from_primitive! { |
32 | | - /// An enum that defines all known packet ids in the context of |
33 | | - /// synchronization and provides a mechanism to convert from |
34 | | - /// packet ids (of type PacketId or u8) directly read from the network |
35 | | - /// to enum variants. This implicitly provides a mechanism to |
36 | | - /// check whether a given packet id is known, and to prevent |
37 | | - /// packet id clashes when defining new ids. |
38 | | - #[derive(Clone, Copy, Debug, PartialEq)] |
39 | | - pub enum SyncPacket { |
40 | | - StatusPacket = 0x00, |
41 | | - NewBlockHashesPacket = 0x01, |
42 | | - TransactionsPacket = 0x02, |
43 | | - GetBlockHeadersPacket = 0x03, |
44 | | - BlockHeadersPacket = 0x04, |
45 | | - GetBlockBodiesPacket = 0x05, |
46 | | - BlockBodiesPacket = 0x06, |
47 | | - NewBlockPacket = 0x07, |
48 | | - |
49 | | - GetNodeDataPacket = 0x0d, |
50 | | - NodeDataPacket = 0x0e, |
51 | | - GetReceiptsPacket = 0x0f, |
52 | | - ReceiptsPacket = 0x10, |
53 | | - |
54 | | - GetSnapshotManifestPacket = 0x11, |
55 | | - SnapshotManifestPacket = 0x12, |
56 | | - GetSnapshotDataPacket = 0x13, |
57 | | - SnapshotDataPacket = 0x14, |
58 | | - ConsensusDataPacket = 0x15, |
59 | | - PrivateTransactionPacket = 0x16, |
60 | | - SignedPrivateTransactionPacket = 0x17, |
61 | | - GetPrivateStatePacket = 0x18, |
62 | | - PrivateStatePacket = 0x19, |
63 | | - } |
| 31 | +/// An enum that defines all known packet ids in the context of |
| 32 | +/// synchronization and provides a mechanism to convert from |
| 33 | +/// packet ids (of type PacketId or u8) directly read from the network |
| 34 | +/// to enum variants. This implicitly provides a mechanism to |
| 35 | +/// check whether a given packet id is known, and to prevent |
| 36 | +/// packet id clashes when defining new ids. |
| 37 | +#[derive(Clone, Copy, Debug, PartialEq, Primitive)] |
| 38 | +pub enum SyncPacket { |
| 39 | + StatusPacket = 0x00, |
| 40 | + NewBlockHashesPacket = 0x01, |
| 41 | + TransactionsPacket = 0x02, |
| 42 | + GetBlockHeadersPacket = 0x03, |
| 43 | + BlockHeadersPacket = 0x04, |
| 44 | + GetBlockBodiesPacket = 0x05, |
| 45 | + BlockBodiesPacket = 0x06, |
| 46 | + NewBlockPacket = 0x07, |
| 47 | + |
| 48 | + GetNodeDataPacket = 0x0d, |
| 49 | + NodeDataPacket = 0x0e, |
| 50 | + GetReceiptsPacket = 0x0f, |
| 51 | + ReceiptsPacket = 0x10, |
| 52 | + |
| 53 | + GetSnapshotManifestPacket = 0x11, |
| 54 | + SnapshotManifestPacket = 0x12, |
| 55 | + GetSnapshotDataPacket = 0x13, |
| 56 | + SnapshotDataPacket = 0x14, |
| 57 | + ConsensusDataPacket = 0x15, |
| 58 | + PrivateTransactionPacket = 0x16, |
| 59 | + SignedPrivateTransactionPacket = 0x17, |
| 60 | + GetPrivateStatePacket = 0x18, |
| 61 | + PrivateStatePacket = 0x19, |
64 | 62 | } |
65 | 63 |
|
66 | 64 |
|
@@ -118,7 +116,7 @@ impl PacketInfo for SyncPacket { |
118 | 116 | #[cfg(test)] |
119 | 117 | mod tests { |
120 | 118 | use super::*; |
121 | | - use enum_primitive::FromPrimitive; |
| 119 | + use num_traits::FromPrimitive; |
122 | 120 |
|
123 | 121 | #[test] |
124 | 122 | fn packet_ids_from_u8_when_from_primitive_zero_then_equals_status_packet() { |
|
0 commit comments