Skip to content

Commit

Permalink
Change Type id::ID in Rust to id::VersionedID
Browse files Browse the repository at this point in the history
  • Loading branch information
666lcz committed Feb 21, 2022
1 parent 3fc772a commit c697bcf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions sui_types/src/coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};

use crate::{
base_types::{ObjectID, SequenceNumber},
id::ID,
id::VersionedID,
SUI_FRAMEWORK_ADDRESS,
};

Expand All @@ -21,12 +21,12 @@ pub const COIN_STRUCT_NAME: &IdentStr = COIN_MODULE_NAME;
// Rust version of the Move FastX::Coin::Coin type
#[derive(Debug, Serialize, Deserialize)]
pub struct Coin {
id: ID,
id: VersionedID,
value: u64,
}

impl Coin {
pub fn new(id: ID, value: u64) -> Self {
pub fn new(id: VersionedID, value: u64) -> Self {
Self { id, value }
}

Expand Down Expand Up @@ -61,7 +61,7 @@ impl Coin {
fields: vec![
MoveFieldLayout::new(
ident_str!("id").to_owned(),
MoveTypeLayout::Struct(ID::layout()),
MoveTypeLayout::Struct(VersionedID::layout()),
),
MoveFieldLayout::new(ident_str!("value").to_owned(), MoveTypeLayout::U64),
],
Expand Down
4 changes: 2 additions & 2 deletions sui_types/src/gas_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
base_types::{ObjectID, SequenceNumber},
coin::Coin,
error::{SuiError, SuiResult},
id::ID,
id::VersionedID,
object::{Data, MoveObject, Object},
SUI_FRAMEWORK_ADDRESS,
};
Expand Down Expand Up @@ -44,7 +44,7 @@ pub struct GasCoin(Coin);

impl GasCoin {
pub fn new(id: ObjectID, version: SequenceNumber, value: u64) -> Self {
Self(Coin::new(ID::new(id, version), value))
Self(Coin::new(VersionedID::new(id, version), value))
}

pub fn value(&self) -> u64 {
Expand Down
4 changes: 2 additions & 2 deletions sui_types/src/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub const ID_BYTES_STRUCT_NAME: &IdentStr = ident_str!("IDBytes");

/// Rust version of the Move FastX::ID::VersionedID type
#[derive(Debug, Serialize, Deserialize)]
pub struct ID {
pub struct VersionedID {
id: IDBytes,
version: u64,
}
Expand All @@ -31,7 +31,7 @@ struct IDBytes {
bytes: ObjectID,
}

impl ID {
impl VersionedID {
pub fn new(bytes: ObjectID, version: SequenceNumber) -> Self {
Self {
id: IDBytes::new(bytes),
Expand Down

1 comment on commit c697bcf

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bench results

�[0m�[0m�[1m�[32m Finished�[0m release [optimized + debuginfo] target(s) in 1.63s
�[0m�[0m�[1m�[32m Running�[0m target/release/bench
�[2m2022-02-21T20:18:55.052666Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Starting benchmark: OrdersAndCerts
�[2m2022-02-21T20:18:55.052690Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Preparing accounts.
�[2m2022-02-21T20:18:55.053635Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Open database on path: "/tmp/DB_2CF6AB9ACD3BCA464673F97B2BC65AACDE7AC89B"
�[2m2022-02-21T20:18:59.860470Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Preparing transactions.
�[2m2022-02-21T20:19:09.185827Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m Listening to TCP traffic on 127.0.0.1:9555
�[2m2022-02-21T20:19:10.187312Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Number of TCP connections: 2
�[2m2022-02-21T20:19:10.187331Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Set max_in_flight to 500
�[2m2022-02-21T20:19:10.187334Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Sending requests.
�[2m2022-02-21T20:19:10.194790Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Sending TCP requests to 127.0.0.1:9555
�[2m2022-02-21T20:19:10.206209Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Sending TCP requests to 127.0.0.1:9555
�[2m2022-02-21T20:19:11.763406Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 5000 packets
�[2m2022-02-21T20:19:12.904408Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 35000
�[2m2022-02-21T20:19:13.229036Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 10000 packets
�[2m2022-02-21T20:19:13.280936Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 35000
�[2m2022-02-21T20:19:14.690559Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 15000 packets
�[2m2022-02-21T20:19:15.823063Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 30000
�[2m2022-02-21T20:19:16.150773Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 20000 packets
�[2m2022-02-21T20:19:16.225418Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 30000
�[2m2022-02-21T20:19:17.508027Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 25000 packets
�[2m2022-02-21T20:19:18.720782Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 25000
�[2m2022-02-21T20:19:18.992308Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 30000 packets
�[2m2022-02-21T20:19:19.054911Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 25000
�[2m2022-02-21T20:19:20.477087Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 35000 packets
�[2m2022-02-21T20:19:21.442550Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 20000
�[2m2022-02-21T20:19:21.643594Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 40000 packets
�[2m2022-02-21T20:19:21.668420Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 20000
�[2m2022-02-21T20:19:22.557374Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 45000 packets
�[2m2022-02-21T20:19:23.258637Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 15000
�[2m2022-02-21T20:19:23.452619Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 50000 packets
�[2m2022-02-21T20:19:23.517148Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 15000
�[2m2022-02-21T20:19:24.344865Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 55000 packets
�[2m2022-02-21T20:19:25.039033Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 10000
�[2m2022-02-21T20:19:25.278901Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 60000 packets
�[2m2022-02-21T20:19:25.315198Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 10000
�[2m2022-02-21T20:19:26.189323Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 65000 packets
�[2m2022-02-21T20:19:26.891523Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 5000
�[2m2022-02-21T20:19:27.090038Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 70000 packets
�[2m2022-02-21T20:19:27.136397Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m In flight 500 Remaining 5000
�[2m2022-02-21T20:19:27.995197Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 75000 packets
�[2m2022-02-21T20:19:28.783486Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Done sending TCP requests to 127.0.0.1:9555
�[2m2022-02-21T20:19:29.017463Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m 127.0.0.1:9555 has processed 80000 packets
�[2m2022-02-21T20:19:29.057733Z�[0m �[32m INFO�[0m �[2msui_network::network�[0m�[2m:�[0m Done sending TCP requests to 127.0.0.1:9555
�[2m2022-02-21T20:19:29.057996Z�[0m �[32m INFO�[0m �[2mbench�[0m�[2m:�[0m Received 80000 responses.
�[2m2022-02-21T20:19:29.260934Z�[0m �[33m WARN�[0m �[2mbench�[0m�[2m:�[0m Completed benchmark for OrdersAndCerts
Total time: 18870649us, items: 40000, tx/sec: 2119.693922556665

Please sign in to comment.