Skip to content

Commit

Permalink
Restore previous Debug impl for PublicKeyBytes (#3445)
Browse files Browse the repository at this point in the history
  • Loading branch information
mystenmark committed Jul 22, 2022
1 parent b8b657f commit 7dd5637
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions crates/sui-types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,20 @@ pub type AggregateAccountSignature = Ed25519AggregateSignature;
//

#[serde_as]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
pub struct PublicKeyBytes(#[serde_as(as = "Readable<Base64, Bytes>")] [u8; PublicKey::LENGTH]);

impl PublicKeyBytes {
fn fmt_impl(
&self,
f: &mut std::fmt::Formatter<'_>,
) -> std::result::Result<(), std::fmt::Error> {
let s = hex::encode(&self.0);
write!(f, "k#{}", s)?;
Ok(())
}
}

impl TryFrom<PublicKeyBytes> for PublicKey {
type Error = signature::Error;

Expand All @@ -70,11 +81,15 @@ impl AsRef<[u8]> for PublicKeyBytes {
}
}

impl std::fmt::Debug for PublicKeyBytes {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
self.fmt_impl(f)
}
}

impl Display for PublicKeyBytes {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
let s = hex::encode(&self.0);
write!(f, "k#{}", s)?;
Ok(())
self.fmt_impl(f)
}
}

Expand Down

1 comment on commit 7dd5637

@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] target(s) in 0.66s
�[0m�[0m�[1m�[32m Running�[0m target/release/bench microbench throughput
Default Jemalloc conf:
�[2m2022-07-23T00:00:09.858555Z�[0m �[32m INFO�[0m �[2msui_benchmark::benchmark�[0m�[2m:�[0m benchmark �[3mbenchmark�[0m�[2m=�[0mBenchmark { committee_size: 1, send_timeout_us: 400000000, recv_timeout_us: 400000000, buffer_size: 65000, tcp_connections: 0, db_cpus: 1, use_native: false, batch_size: 2000, running_mode: SingleValidatorThread, working_dir: None, bench_type: MicroBenchmark { host: "127.0.0.1", port: 9555, type_: Throughput { num_transactions: 100000 } } }
Jemalloc: 1 MB allocated / 9 MB resident
�[2m2022-07-23T00:00:09.859640Z�[0m �[32m INFO�[0m �[2msui_config::genesis_config�[0m�[2m:�[0m Creating accounts and gas objects...
�[2m2022-07-23T00:00:09.877288Z�[0m �[32m INFO�[0m �[2msui_benchmark::benchmark::validator_preparer�[0m�[2m:�[0m authority address hex: 0x545e4ed0bd15008db34dd85d3ee7500ce3990557
�[2m2022-07-23T00:00:09.877414Z�[0m �[32m INFO�[0m �[2msui_benchmark::benchmark::validator_preparer�[0m�[2m:�[0m Open database on path: "/tmp/DB_0xef029a08e8b22b73afe04be907b7aa262397affc"
�[2m2022-07-23T00:00:10.097619Z�[0m �[32m INFO�[0m �[2msui_storage::lock_service�[0m�[2m:�[0m LockService command processing loop started
�[2m2022-07-23T00:00:10.097688Z�[0m �[32m INFO�[0m �[2msui_storage::lock_service�[0m�[2m:�[0m LockService queries processing loop started
�[2m2022-07-23T00:00:10.772639Z�[0m �[32m INFO�[0m �[2msui_benchmark::benchmark::validator_preparer�[0m�[2m:�[0m Spawning a validator thread...
�[2m2022-07-23T00:00:10.774085Z�[0m �[32m INFO�[0m �[2msui_core::authority_server�[0m�[2m:�[0m Listening to traffic on /dns/127.0.0.1/tcp/9555/http
Jemalloc: 66 MB allocated / 145 MB resident
Jemalloc: 67 MB allocated / 139 MB resident
Jemalloc: 125 MB allocated / 173 MB resident
Jemalloc: 967 MB allocated / 1938 MB resident
Throughout: 50864.285946808166 tps

Please sign in to comment.