mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-14 19:25:51 +00:00
WalletProtobufSerializer: Add property to require all found wallet extensions to be known when loading wallet.
Corrected copy pasted text, add warning when ignoring extension due to parsing failure.
This commit is contained in:
parent
072106a53b
commit
22beb447d1
@ -79,6 +79,7 @@ public class WalletProtobufSerializer {
|
||||
protected Map<ByteString, Transaction> txMap;
|
||||
|
||||
private boolean requireMandatoryExtensions = true;
|
||||
private boolean requireAllExtensionsKnown = false;
|
||||
private int walletWriteBufferSize = CodedOutputStream.DEFAULT_BUFFER_SIZE;
|
||||
|
||||
public interface WalletFactory {
|
||||
@ -116,6 +117,13 @@ public class WalletProtobufSerializer {
|
||||
requireMandatoryExtensions = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* If this property is set to true, the wallet will fail to load if any found extensions are unknown..
|
||||
*/
|
||||
public void setRequireAllExtensionsKnown(boolean value) {
|
||||
requireAllExtensionsKnown = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change buffer size for writing wallet to output stream. Default is {@link com.google.protobuf.CodedOutputStream.DEFAULT_BUFFER_SIZE}
|
||||
* @param walletWriteBufferSize - buffer size in bytes
|
||||
@ -584,6 +592,8 @@ public class WalletProtobufSerializer {
|
||||
throw new UnreadableWalletException("Unknown mandatory extension in wallet: " + id);
|
||||
else
|
||||
log.error("Unknown extension in wallet {}, ignoring", id);
|
||||
} else if (requireAllExtensionsKnown) {
|
||||
throw new UnreadableWalletException("Unknown extension in wallet: " + id);
|
||||
}
|
||||
} else {
|
||||
log.info("Loading wallet extension {}", id);
|
||||
@ -593,6 +603,11 @@ public class WalletProtobufSerializer {
|
||||
if (extProto.getMandatory() && requireMandatoryExtensions) {
|
||||
log.error("Error whilst reading mandatory extension {}, failing to read wallet", id);
|
||||
throw new UnreadableWalletException("Could not parse mandatory extension in wallet: " + id);
|
||||
} else if (requireAllExtensionsKnown) {
|
||||
log.error("Error whilst reading extension {}, failing to read wallet", id);
|
||||
throw new UnreadableWalletException("Could not parse extension in wallet: " + id);
|
||||
} else {
|
||||
log.warn("Error whilst reading extension {}, ignoring extension", id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user