Skip to content

Commit 3bc5ede

Browse files
Seulgi Kimsgkim126
authored andcommitted
Reduce the size of network_id to u32
1 parent 049e649 commit 3bc5ede

File tree

14 files changed

+24
-23
lines changed

14 files changed

+24
-23
lines changed

codechain/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
pub const DEFAULT_CONFIG_PATH: &'static str = "codechain/config/presets/config.dev.toml";
1818
pub const DEFAULT_KEYS_PATH: &'static str = "keys";
19-
pub const DEFAULT_NETWORK_ID: u64 = 0x11;
19+
pub const DEFAULT_NETWORK_ID: u32 = 0x11;

core/src/client/test_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl TestBlockChainClient {
198198
let parcel = Parcel {
199199
nonce: U256::zero(),
200200
fee: U256::from(10),
201-
network_id: 0u64,
201+
network_id: 0,
202202
action: Action::ChangeShardState {
203203
transactions: vec![],
204204
changes: vec![],
@@ -266,7 +266,7 @@ impl TestBlockChainClient {
266266
let parcel = Parcel {
267267
nonce: U256::zero(),
268268
fee: U256::from(10),
269-
network_id: 0u64,
269+
network_id: 0,
270270
action: Action::ChangeShardState {
271271
transactions,
272272
changes: vec![],

core/src/miner/local_parcels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ mod tests {
222222
changes: vec![],
223223
signatures: vec![],
224224
},
225-
network_id: 0u64,
225+
network_id: 0,
226226
};
227227
SignedParcel::new_with_sign(parcel, keypair.private())
228228
}

core/src/spec/spec.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct CommonParams {
4949
/// Maximum size of metadata.
5050
pub max_metadata_size: usize,
5151
/// Network id.
52-
pub network_id: u64,
52+
pub network_id: u32,
5353
/// Minimum parcel cost.
5454
pub min_parcel_cost: U256,
5555
/// Maximum size of block body.
@@ -62,10 +62,11 @@ pub struct CommonParams {
6262

6363
impl From<cjson::spec::Params> for CommonParams {
6464
fn from(p: cjson::spec::Params) -> Self {
65+
let network_id: u64 = p.network_id.into();
6566
Self {
6667
max_extra_data_size: p.max_extra_data_size.into(),
6768
max_metadata_size: p.max_metadata_size.into(),
68-
network_id: p.network_id.into(),
69+
network_id: network_id as u32,
6970
min_parcel_cost: p.min_parcel_cost.into(),
7071
max_body_size: p.max_body_size.into(),
7172
snapshot_period: p.snapshot_period.into(),

docs/parcel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ A parcel would look something like this:
2828
pub struct Parcel {
2929
pub nonce: U256,
3030
pub fee: U256,
31-
pub network_id: u64,
31+
pub network_id: u32,
3232
pub action: Action,
3333
}
3434

@@ -46,4 +46,4 @@ A parcel would look something like this:
4646
}
4747

4848
The fee of the parcel would determine its priority, meaning, how quickly it gets processed. In addition, there is
49-
also a minimum fee that can be set. The nonce property exists for the purpose of preventing replay attacks.
49+
also a minimum fee that can be set. The nonce property exists for the purpose of preventing replay attacks.

key/src/address.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub struct FullAddress {
168168
}
169169

170170
impl FullAddress {
171-
pub fn create_version0(network_id: u64, address: Address) -> Result<Self, Error> {
171+
pub fn create_version0(network_id: u32, address: Address) -> Result<Self, Error> {
172172
let network = match network_id {
173173
// FIXME: 0x11 is the network id for SOLO
174174
0x11 => Network::Mainnet,

rpc/src/v1/impls/account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ use super::super::traits::Account;
2626

2727
pub struct AccountClient {
2828
account_provider: Arc<AccountProvider>,
29-
network_id: u64,
29+
network_id: u32,
3030
}
3131

3232
impl AccountClient {
33-
pub fn new(ap: &Arc<AccountProvider>, network_id: u64) -> Self {
33+
pub fn new(ap: &Arc<AccountProvider>, network_id: u32) -> Self {
3434
AccountClient {
3535
account_provider: ap.clone(),
3636
network_id,

rpc/src/v1/impls/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ where
192192
}
193193
}
194194

195-
fn get_network_id(&self) -> Result<u64> {
195+
fn get_network_id(&self) -> Result<u32> {
196196
Ok(self.client.common_params().network_id)
197197
}
198198

rpc/src/v1/traits/chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ build_rpc_trait! {
114114

115115
/// Return the network id that is used in this chain.
116116
# [rpc(name = "chain_getNetworkId")]
117-
fn get_network_id(&self) -> Result<u64>;
117+
fn get_network_id(&self) -> Result<u32>;
118118

119119
/// Execute Transactions
120120
# [rpc(name = "chain_executeTransactions")]

rpc/src/v1/types/parcel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub struct Parcel {
2727
pub parcel_index: Option<usize>,
2828
pub nonce: U256,
2929
pub fee: U256,
30-
pub network_id: u64,
30+
pub network_id: u32,
3131
pub action: Action,
3232
pub hash: H256,
3333
pub sig: Signature,

0 commit comments

Comments
 (0)