Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 596d011

Browse files
authored
Upgrade num to 0.2, use enum-primitive-derive (#11636)
1 parent 58fde98 commit 596d011

File tree

6 files changed

+75
-76
lines changed

6 files changed

+75
-76
lines changed

Cargo.lock

Lines changed: 37 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ethcore/builtin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ethereum-types = "0.9.0"
1414
ethjson = { path = "../../json" }
1515
keccak-hash = "0.5.0"
1616
log = "0.4"
17-
num = { version = "0.1", default-features = false, features = ["bigint"] }
17+
num = "0.2"
1818
parity-bytes = "0.1"
1919
parity-crypto = { version = "0.6.1", features = ["publickey"] }
2020
eth_pairings = { git = "https://github.com/matter-labs/eip1962.git", default-features = false, features = ["eip_2537"], rev = "ece6cbabc41948db4200e41f0bfdab7ab94c7af8" }

ethcore/sync/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bytes = { package = "parity-bytes", version = "0.1" }
1313
client-traits = { path = "../client-traits" }
1414
common-types = { path = "../types" }
1515
devp2p = { package = "ethcore-network-devp2p", path = "../../util/network-devp2p" }
16-
enum_primitive = "0.1.1"
16+
enum-primitive-derive = "0.2"
1717
ethcore-io = { path = "../../util/io" }
1818
ethcore-private-tx = { path = "../private-tx" }
1919
ethereum-forkid = "0.2"
@@ -25,6 +25,7 @@ keccak-hash = "0.5.0"
2525
light = { package = "ethcore-light", path = "../light" }
2626
log = "0.4"
2727
network = { package = "ethcore-network", path = "../../util/network" }
28+
num-traits = "0.2"
2829
parity-runtime = "0.1.1"
2930
parity-crypto = { version = "0.6.1", features = ["publickey"] }
3031
parity-util-mem = "0.6.0"

ethcore/sync/src/chain/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use crate::{
3838
};
3939

4040
use bytes::Bytes;
41-
use enum_primitive::FromPrimitive;
41+
use num_traits::FromPrimitive;
4242
use ethereum_types::{H256, U256};
4343
use keccak_hash::keccak;
4444
use network::PeerId;

ethcore/sync/src/chain/supplier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::time::{Duration, Instant};
2020
use crate::sync_io::SyncIo;
2121

2222
use bytes::Bytes;
23-
use enum_primitive::FromPrimitive;
23+
use num_traits::FromPrimitive;
2424
use ethereum_types::H256;
2525
use log::{debug, trace, warn};
2626
use network::{self, PeerId};

ethcore/sync/src/chain/sync_packet.rs

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,42 +25,40 @@
2525
use crate::api::{ETH_PROTOCOL, WARP_SYNC_PROTOCOL_ID};
2626
use self::SyncPacket::*;
2727

28-
use enum_primitive::{enum_from_primitive, enum_from_primitive_impl, enum_from_primitive_impl_ty};
28+
use enum_primitive_derive::Primitive;
2929
use network::{PacketId, ProtocolId};
3030

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,
6462
}
6563

6664

@@ -118,7 +116,7 @@ impl PacketInfo for SyncPacket {
118116
#[cfg(test)]
119117
mod tests {
120118
use super::*;
121-
use enum_primitive::FromPrimitive;
119+
use num_traits::FromPrimitive;
122120

123121
#[test]
124122
fn packet_ids_from_u8_when_from_primitive_zero_then_equals_status_packet() {

0 commit comments

Comments
 (0)