mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 02:05:53 +00:00
Replace duplicated "current wallet version" constant by code that looks it up from the .proto itself.
This commit is contained in:
parent
20955814bb
commit
53688cde60
@ -72,7 +72,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class WalletProtobufSerializer {
|
||||
private static final Logger log = LoggerFactory.getLogger(WalletProtobufSerializer.class);
|
||||
|
||||
/** Current version used for serializing wallets. A version higher than this is considered from the future. */
|
||||
public static final int CURRENT_WALLET_VERSION = Protos.Wallet.getDefaultInstance().getVersion();
|
||||
// Used for de-serialization
|
||||
protected Map<ByteString, Transaction> txMap;
|
||||
|
||||
@ -404,7 +405,7 @@ public class WalletProtobufSerializer {
|
||||
*/
|
||||
public Wallet readWallet(NetworkParameters params, @Nullable WalletExtension[] extensions,
|
||||
Protos.Wallet walletProto) throws UnreadableWalletException {
|
||||
if (walletProto.getVersion() > 1)
|
||||
if (walletProto.getVersion() > CURRENT_WALLET_VERSION)
|
||||
throw new UnreadableWalletException.FutureVersion();
|
||||
if (!walletProto.getNetworkIdentifier().equals(params.getId()))
|
||||
throw new UnreadableWalletException.WrongNetwork();
|
||||
|
@ -360,7 +360,8 @@ message Wallet {
|
||||
optional ScryptParameters encryption_parameters = 6;
|
||||
|
||||
// The version number of the wallet - used to detect wallets that were produced in the future
|
||||
// (i.e the wallet may contain some future format this protobuf/ code does not know about)
|
||||
// (i.e. the wallet may contain some future format this protobuf or parser code does not know about).
|
||||
// A version that's higher than the default is considered from the future.
|
||||
optional int32 version = 7 [default = 1];
|
||||
|
||||
// deprecated - do not recycle this numeric identifier
|
||||
|
Loading…
x
Reference in New Issue
Block a user