mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-03 14:07:14 +00:00
When deserializing wallet extensions, lock order is now wallet and then extension.
This commit is contained in:
committed by
Andreas Schildbach
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
|
@Override
|
||||||
public synchronized void setTag(String tag, ByteString value) {
|
public synchronized void setTag(String tag, ByteString value) {
|
||||||
super.setTag(tag, value);
|
super.setTag(tag, value);
|
||||||
|
|||||||
@@ -513,13 +513,14 @@ public class WalletProtobufSerializer {
|
|||||||
} else {
|
} else {
|
||||||
log.info("Loading wallet extension {}", id);
|
log.info("Loading wallet extension {}", id);
|
||||||
try {
|
try {
|
||||||
extension.deserializeWalletExtension(wallet, extProto.getData().toByteArray());
|
wallet.deserializeAndAddExtension(extension, extProto.getData().toByteArray());
|
||||||
wallet.addOrGetExistingExtension(extension);
|
|
||||||
} catch (Exception e) {
|
} 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);
|
throw new UnreadableWalletException("Could not parse mandatory extension in wallet: " + id);
|
||||||
else
|
} else {
|
||||||
log.error("Error whilst reading extension {}, ignoring", id, e);
|
log.error("Error whilst reading extension {}, ignoring", id, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user