Box value encoded in a variant to reduce enum stack space

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
```
This commit is contained in:
Riccardo Casatta 2022-05-19 17:05:42 +02:00
parent 491da3e701
commit 9906cea14c
No known key found for this signature in database
GPG Key ID: FD986A969E450397
2 changed files with 2 additions and 2 deletions

View File

@ -80,7 +80,7 @@ pub enum Error {
},
/// Conflicting data during combine procedure:
/// global extended public key has inconsistent key sources
CombineInconsistentKeySources(ExtendedPubKey),
CombineInconsistentKeySources(Box<ExtendedPubKey>),
/// Serialization error in bitcoin consensus-encoded structures
ConsensusEncoding,
}

View File

@ -194,7 +194,7 @@ impl PartiallySignedTransaction {
entry.insert((fingerprint1, derivation1));
continue
}
return Err(Error::CombineInconsistentKeySources(xpub));
return Err(Error::CombineInconsistentKeySources(Box::new(xpub)));
}
}
}