Skip to content

Commit 0c07bdd

Browse files
committed
chored(build): fix merkle address to_string
1 parent 2e78e36 commit 0c07bdd

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

p2p/src/channels/rpc/mod.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,23 @@ impl Default for P2pRpcRequest {
109109
}
110110
}
111111

112-
fn to_binary(bytes: &[u8]) -> String {
113-
bytes
112+
fn addr_to_str(
113+
MerkleAddressBinableArgStableV1(mina_p2p_messages::number::Number(length), byte_string): &MerkleAddressBinableArgStableV1,
114+
) -> String {
115+
let addr = byte_string
116+
.as_ref()
114117
.into_iter()
115118
.copied()
116-
.map(|byte| {
119+
.flat_map(|byte| {
117120
(0..8)
118121
.into_iter()
119-
.map(|b| byte & (1 << (7 - b)) != 0)
122+
.map(move |b| byte & (1 << (7 - b)) != 0)
120123
.map(|b| if b { '1' } else { '0' })
121-
.collect::<String>()
122124
})
123-
.collect()
125+
.take(*length as usize)
126+
.collect::<String>();
127+
128+
format!("depth: {length}, addr: {addr}")
124129
}
125130

126131
impl std::fmt::Display for P2pRpcRequest {
@@ -129,12 +134,6 @@ impl std::fmt::Display for P2pRpcRequest {
129134
match self {
130135
Self::BestTipWithProof => Ok(()),
131136
Self::LedgerQuery(ledger_hash, query) => {
132-
let addr_to_str = |addr: &MerkleAddressBinableArgStableV1| {
133-
let depth = &addr.0 .0;
134-
let bits = to_binary(&addr.1[..(*depth as usize)]);
135-
format!("depth: {depth}, addr: {bits}")
136-
};
137-
138137
match query {
139138
MinaLedgerSyncLedgerQueryStableV1::NumAccounts => write!(f, ", NumAccounts, ")?,
140139
MinaLedgerSyncLedgerQueryStableV1::WhatChildHashes(addr) => {

0 commit comments

Comments
 (0)