mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-20 02:09:29 +01:00
When deserializing wallet extensions, lock order is now wallet and then extension.
This commit is contained in:
parent
af20c37a8d
commit
e3a13a6efa
@ -3972,6 +3972,26 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize the wallet extension with the supplied data and add
|
||||
* it to the wallet, unless there exists an extension with the
|
||||
* same id.
|
||||
*/
|
||||
public void deserializeAndAddExtension(WalletExtension extension, byte[] data) throws Exception {
|
||||
String id = checkNotNull(extension).getWalletExtensionID();
|
||||
lock.lock();
|
||||
try {
|
||||
if (extensions.containsKey(id)) {
|
||||
return;
|
||||
} else {
|
||||
extension.deserializeWalletExtension(this, data);
|
||||
addExtension(extension);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setTag(String tag, ByteString value) {
|
||||
super.setTag(tag, value);
|
||||
|
@ -513,13 +513,14 @@ public class WalletProtobufSerializer {
|
||||
} else {
|
||||
log.info("Loading wallet extension {}", id);
|
||||
try {
|
||||
extension.deserializeWalletExtension(wallet, extProto.getData().toByteArray());
|
||||
wallet.addOrGetExistingExtension(extension);
|
||||
wallet.deserializeAndAddExtension(extension, extProto.getData().toByteArray());
|
||||
} catch (Exception e) {
|
||||
if (extProto.getMandatory() && requireMandatoryExtensions)
|
||||
if (extProto.getMandatory() && requireMandatoryExtensions) {
|
||||
log.error("Error whilst reading extension {}, failing to read wallet", id, e);
|
||||
throw new UnreadableWalletException("Could not parse mandatory extension in wallet: " + id);
|
||||
else
|
||||
} else {
|
||||
log.error("Error whilst reading extension {}, ignoring", id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user