Skip to content

Commit c2d06a2

Browse files
author
ChallengeDev210
committed
Merge rust-bitcoin/rust-bitcoin#996: Box value encoded in a variant to reduce enum stack space
9906cea Box value encoded in a variant to reduce enum stack space (Riccardo Casatta) Pull request description: before ``` print-type-size type: `util::psbt::error::Error`: 120 bytes, alignment: 8 bytes print-type-size discriminant: 1 bytes print-type-size variant `CombineInconsistentKeySources`: 115 bytes print-type-size padding: 3 bytes print-type-size field `.0`: 112 bytes, alignment: 4 bytes print-type-size variant `InvalidKey`: 39 bytes print-type-size padding: 7 bytes print-type-size field `.0`: 32 bytes, alignment: 8 bytes ``` after ``` print-type-size type: `util::psbt::error::Error`: 40 bytes, alignment: 8 bytes print-type-size discriminant: 1 bytes print-type-size variant `InvalidKey`: 39 bytes print-type-size padding: 7 bytes print-type-size field `.0`: 32 bytes, alignment: 8 bytes print-type-size variant `DuplicateKey`: 39 bytes print-type-size padding: 7 bytes print-type-size field `.0`: 32 bytes, alignment: 8 bytes ``` `util::psbt::error::Error` is wrapped also in `consensus::encode::Error` and stack savings are gained there also ACKs for top commit: apoelstra: ACK 9906cea tcharding: ACK 9906cea sanket1729: utACK 9906cea Tree-SHA512: e03988fcbc3dd87f83d00dd84ec1c538bc5c63bea97ff4a69a715621f498f57d7fe2a623e351942d9532af40c723e42a9eb6ef48ebf4c62ddf5c0f44e9ea0a07
2 parents 645ab64 + 572e190 commit c2d06a2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/util/psbt/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub enum Error {
8080
},
8181
/// Conflicting data during combine procedure:
8282
/// global extended public key has inconsistent key sources
83-
CombineInconsistentKeySources(ExtendedPubKey),
83+
CombineInconsistentKeySources(Box<ExtendedPubKey>),
8484
/// Serialization error in bitcoin consensus-encoded structures
8585
ConsensusEncoding,
8686
}

src/util/psbt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl PartiallySignedTransaction {
192192
entry.insert((fingerprint1, derivation1));
193193
continue
194194
}
195-
return Err(Error::CombineInconsistentKeySources(xpub));
195+
return Err(Error::CombineInconsistentKeySources(Box::new(xpub)));
196196
}
197197
}
198198
}

0 commit comments

Comments
 (0)