Skip to content

Commit 4e7b435

Browse files
committed
fix build
1 parent ae57f0e commit 4e7b435

File tree

28 files changed

+116
-139
lines changed

28 files changed

+116
-139
lines changed

src/catalyst-toolbox/catalyst-toolbox/tests/tally/main.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ fn tally_ok() {
9999

100100
let (ledger, failed_fragments) = catalyst_toolbox::recovery::tally::recover_ledger_from_logs(
101101
&generator.block0(),
102-
vote_fragments
103-
.into_iter()
104-
.chain(tally_fragments),
102+
vote_fragments.into_iter().chain(tally_fragments),
105103
)
106104
.unwrap();
107105

@@ -127,9 +125,7 @@ fn shuffle_tally_ok() {
127125

128126
let (ledger, _) = catalyst_toolbox::recovery::tally::recover_ledger_from_logs(
129127
&generator.block0(),
130-
vote_fragments
131-
.into_iter()
132-
.chain(tally_fragments),
128+
vote_fragments.into_iter().chain(tally_fragments),
133129
)
134130
.unwrap();
135131

@@ -153,9 +149,7 @@ fn shuffle_tally_ok_private() {
153149

154150
let (ledger, _) = catalyst_toolbox::recovery::tally::recover_ledger_from_logs(
155151
&generator.block0(),
156-
vote_fragments
157-
.into_iter()
158-
.chain(tally_fragments),
152+
vote_fragments.into_iter().chain(tally_fragments),
159153
)
160154
.unwrap();
161155

@@ -323,9 +317,7 @@ fn multi_voteplan_ok() {
323317

324318
let (ledger, _) = catalyst_toolbox::recovery::tally::recover_ledger_from_logs(
325319
&generator.block0(),
326-
vote_fragments
327-
.into_iter()
328-
.chain(tally_fragments),
320+
vote_fragments.into_iter().chain(tally_fragments),
329321
)
330322
.unwrap();
331323

@@ -353,9 +345,7 @@ fn multi_voteplan_ok_private() {
353345

354346
let (ledger, _) = catalyst_toolbox::recovery::tally::recover_ledger_from_logs(
355347
&generator.block0(),
356-
vote_fragments
357-
.into_iter()
358-
.chain(tally_fragments),
348+
vote_fragments.into_iter().chain(tally_fragments),
359349
)
360350
.unwrap();
361351

@@ -553,9 +543,7 @@ fn expired_transaction() {
553543

554544
let (ledger, failed_fragments) = catalyst_toolbox::recovery::tally::recover_ledger_from_logs(
555545
&generator.block0(),
556-
vec![fragment_yes]
557-
.into_iter()
558-
.chain(tally_fragments),
546+
vec![fragment_yes].into_iter().chain(tally_fragments),
559547
)
560548
.unwrap();
561549

src/chain-libs/cardano-legacy-address/src/base58.rs

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,76 @@ pub fn decode(input: &str) -> Result<Vec<u8>> {
3131
base_decode(ALPHABET, input.as_bytes())
3232
}
3333

34+
fn base_encode(alphabet_s: &str, input: &[u8]) -> Vec<u8> {
35+
let alphabet = alphabet_s.as_bytes();
36+
let base = alphabet.len() as u32;
37+
38+
let mut digits = vec![0u8];
39+
for input in input.iter() {
40+
let mut carry = *input as u32;
41+
for digit in digits.iter_mut() {
42+
carry += (*digit as u32) << 8;
43+
*digit = (carry % base) as u8;
44+
carry /= base;
45+
}
46+
47+
while carry > 0 {
48+
digits.push((carry % base) as u8);
49+
carry /= base;
50+
}
51+
}
52+
53+
let mut string = vec![];
54+
55+
let mut k = 0;
56+
while (k < input.len()) && (input[k] == 0) {
57+
string.push(alphabet[0]);
58+
k += 1;
59+
}
60+
for digit in digits.iter().rev() {
61+
string.push(alphabet[*digit as usize]);
62+
}
63+
64+
string
65+
}
66+
67+
fn base_decode(alphabet_s: &str, input: &[u8]) -> Result<Vec<u8>> {
68+
let alphabet = alphabet_s.as_bytes();
69+
let base = alphabet.len() as u32;
70+
71+
let mut bytes: Vec<u8> = vec![0];
72+
let zcount = input.iter().take_while(|x| **x == alphabet[0]).count();
73+
74+
for (i, input) in input[zcount..].iter().enumerate() {
75+
let value = match alphabet.iter().position(|&x| x == *input) {
76+
Some(idx) => idx,
77+
None => return Err(Error::UnknownSymbol(i)),
78+
};
79+
let mut carry = value as u32;
80+
for byte in bytes.iter_mut() {
81+
carry += (*byte as u32) * base;
82+
*byte = carry as u8;
83+
carry >>= 8;
84+
}
85+
86+
while carry > 0 {
87+
bytes.push(carry as u8);
88+
carry >>= 8;
89+
}
90+
}
91+
let leading_zeros = bytes.iter().rev().take_while(|x| **x == 0).count();
92+
if zcount > leading_zeros {
93+
let unpad = if leading_zeros > 0 {
94+
leading_zeros + 1
95+
} else {
96+
0
97+
};
98+
bytes.resize(bytes.len() + zcount - unpad, 0);
99+
}
100+
bytes.reverse();
101+
Ok(bytes)
102+
}
103+
34104
/// decode from base58 the given input
35105
//pub fn decode_bytes(input: &[u8]) -> Result<Vec<u8>> {
36106
// base_decode(ALPHABET, input)
@@ -101,73 +171,3 @@ mod tests {
101171
);
102172
}
103173
}
104-
105-
fn base_encode(alphabet_s: &str, input: &[u8]) -> Vec<u8> {
106-
let alphabet = alphabet_s.as_bytes();
107-
let base = alphabet.len() as u32;
108-
109-
let mut digits = vec![0u8];
110-
for input in input.iter() {
111-
let mut carry = *input as u32;
112-
for digit in digits.iter_mut() {
113-
carry += (*digit as u32) << 8;
114-
*digit = (carry % base) as u8;
115-
carry /= base;
116-
}
117-
118-
while carry > 0 {
119-
digits.push((carry % base) as u8);
120-
carry /= base;
121-
}
122-
}
123-
124-
let mut string = vec![];
125-
126-
let mut k = 0;
127-
while (k < input.len()) && (input[k] == 0) {
128-
string.push(alphabet[0]);
129-
k += 1;
130-
}
131-
for digit in digits.iter().rev() {
132-
string.push(alphabet[*digit as usize]);
133-
}
134-
135-
string
136-
}
137-
138-
fn base_decode(alphabet_s: &str, input: &[u8]) -> Result<Vec<u8>> {
139-
let alphabet = alphabet_s.as_bytes();
140-
let base = alphabet.len() as u32;
141-
142-
let mut bytes: Vec<u8> = vec![0];
143-
let zcount = input.iter().take_while(|x| **x == alphabet[0]).count();
144-
145-
for (i, input) in input[zcount..].iter().enumerate() {
146-
let value = match alphabet.iter().position(|&x| x == *input) {
147-
Some(idx) => idx,
148-
None => return Err(Error::UnknownSymbol(i)),
149-
};
150-
let mut carry = value as u32;
151-
for byte in bytes.iter_mut() {
152-
carry += (*byte as u32) * base;
153-
*byte = carry as u8;
154-
carry >>= 8;
155-
}
156-
157-
while carry > 0 {
158-
bytes.push(carry as u8);
159-
carry >>= 8;
160-
}
161-
}
162-
let leading_zeros = bytes.iter().rev().take_while(|x| **x == 0).count();
163-
if zcount > leading_zeros {
164-
let unpad = if leading_zeros > 0 {
165-
leading_zeros + 1
166-
} else {
167-
0
168-
};
169-
bytes.resize(bytes.len() + zcount - unpad, 0);
170-
}
171-
bytes.reverse();
172-
Ok(bytes)
173-
}

src/chain-libs/chain-crypto/src/asymlock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn encrypt<R: RngCore + CryptoRng>(
6969
/// * data is too small
7070
/// * point is not in the first format
7171
/// * tag don't match
72-
/// Success otherwise
72+
/// Success otherwise
7373
///
7474
/// # Panics
7575
///

src/chain-libs/chain-crypto/src/digest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<H: DigestAlg, T> Eq for DigestOf<H, T> {}
309309

310310
impl<H: DigestAlg, T> PartialOrd for DigestOf<H, T> {
311311
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
312-
self.inner.partial_cmp(&other.inner)
312+
Some(self.cmp(other))
313313
}
314314
}
315315

src/chain-libs/chain-crypto/src/key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ impl<A: AsymmetricPublicKey> std::cmp::Eq for PublicKey<A> {}
235235

236236
impl<A: AsymmetricPublicKey> std::cmp::PartialOrd<Self> for PublicKey<A> {
237237
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
238-
self.0.as_ref().partial_cmp(other.0.as_ref())
238+
Some(self.cmp(other))
239239
}
240240
}
241241

src/chain-libs/chain-crypto/src/multilock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn encrypt<R: RngCore + CryptoRng>(
148148
/// * data is too small
149149
/// * any of the point is not in the first format
150150
/// * tag don't match
151-
/// Success otherwise
151+
/// Success otherwise
152152
///
153153
/// # Panics
154154
///

src/chain-libs/chain-crypto/src/role.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<R, A: key::AsymmetricPublicKey> std::cmp::Eq for PublicKey<R, A> {}
7575

7676
impl<R, A: key::AsymmetricPublicKey> std::cmp::PartialOrd<Self> for PublicKey<R, A> {
7777
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
78-
self.inner.partial_cmp(&other.inner)
78+
Some(self.cmp(other))
7979
}
8080
}
8181

src/chain-libs/chain-impl-mockchain/src/testing/arbitrary/transaction.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ impl UtxoVerifier {
276276

277277
let utxo_not_changed: Vec<AddressDataValue> = all
278278
.iter()
279-
.filter(|&x| filter_utxo(x)).filter(|&x| !inputs.contains(x)).cloned()
279+
.filter(|&x| filter_utxo(x))
280+
.filter(|&x| !inputs.contains(x))
281+
.cloned()
280282
.collect();
281283
let utxo_added: Vec<AddressDataValue> = outputs
282284
.iter()

src/chain-libs/chain-ser/src/abor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ mod tests {
302302
let v2 = 0x12345;
303303
let v3 = 0xffee_ddcc_0011_2233;
304304
let v4 = 0xff_eedd_cc00_1122_3321_4902_1948_0912;
305-
let bs1 = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
305+
let bs1 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
306306
let e = Encoder::new()
307307
.u16(v1)
308308
.u32(v2)

src/chain-libs/chain-storage/src/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ fn branch_pruning() {
320320
hs.insert(second_branch_blocks.last().unwrap().id.serialize_as_value());
321321
hs
322322
};
323-
let actual_tips = HashSet::from_iter(store.get_tips_ids().unwrap().into_iter());
323+
let actual_tips = HashSet::from_iter(store.get_tips_ids().unwrap());
324324
assert_eq!(expected_tips, actual_tips);
325325

326326
store
@@ -397,8 +397,7 @@ fn get_blocks_by_chain_length() {
397397
let actual = HashSet::from_iter(
398398
store
399399
.get_blocks_by_chain_length(chain_length)
400-
.unwrap()
401-
.into_iter(),
400+
.unwrap(),
402401
);
403402

404403
assert_eq!(expected, actual);

0 commit comments

Comments
 (0)