From ce927609ba2ad666ce8fcbb50c01a4b41c77f5f8 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Sun, 27 Mar 2011 21:16:16 +0000 Subject: [PATCH] Add synchronized to a couple of methods. Bit more style consistency in Wallet. --- src/com/google/bitcoin/core/Wallet.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com/google/bitcoin/core/Wallet.java b/src/com/google/bitcoin/core/Wallet.java index d34bf20b..a7b94622 100644 --- a/src/com/google/bitcoin/core/Wallet.java +++ b/src/com/google/bitcoin/core/Wallet.java @@ -53,6 +53,7 @@ public class Wallet implements Serializable { /** A list of public/private EC keys owned by this user. */ public final ArrayList keychain; + private final NetworkParameters params; transient private ArrayList eventListeners; @@ -81,7 +82,7 @@ public class Wallet implements Serializable { /** * Returns a wallet deserialized from the given file. */ - static public Wallet loadFromFile(File f) throws IOException { + public static Wallet loadFromFile(File f) throws IOException { ObjectInputStream ois = null; try { ois = new ObjectInputStream(new FileInputStream(f)); @@ -351,7 +352,7 @@ public class Wallet implements Serializable { } @Override - public String toString() { + public synchronized String toString() { StringBuilder builder = new StringBuilder(); builder.append("Wallet containing "); builder.append(Utils.bitcoinValueToFriendlyString(getBalance())); @@ -378,7 +379,7 @@ public class Wallet implements Serializable { * to go down in this case: money we thought we had can suddenly vanish if the rest of the network agrees it * should be so. */ - void reorganize(StoredBlock chainHead, StoredBlock newStoredBlock) { + synchronized void reorganize(StoredBlock chainHead, StoredBlock newStoredBlock) { // This runs on any peer thread with the block chain synchronized. Thus we do not have to worry about it // being called simultaneously or repeatedly. LOG("Re-organize!");