Permalink
Browse files

added onReorganise. updated izpack installer

  • Loading branch information...
1 parent e61b092 commit eda353d063b58f98bc9e5862df4c2a54ac0f9f1d @jim618 jim618 committed Dec 1, 2011
View
12 pom.xml
@@ -478,11 +478,6 @@
<artifactId>javase</artifactId>
<version>1.6</version>
</dependency>
- <dependency>
- <groupId>org.codehaus.izpack</groupId>
- <artifactId>izpack-standalone-compiler</artifactId>
- <version>4.3.4</version>
- </dependency>
<dependency>
<groupId>org.simplericity.macify</groupId>
<artifactId>macify</artifactId>
@@ -496,6 +491,13 @@
<version>0.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.izpack</groupId>
+ <artifactId>izpack</artifactId>
+ <version>5.0.0-beta8</version>
+ <type>pom</type>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<reporting>
<plugins>
@@ -17,8 +17,8 @@
-->
<info>
<appname>MultiBit</appname>
- <appsubpath>MultiBit-0.2.0beta2</appsubpath>
- <appversion>0.2.0beta2</appversion>
+ <appsubpath>MultiBit-0.2.0beta3</appsubpath>
+ <appversion>0.2.0beta3</appversion>
<url>http://multibit.org/</url>
<uninstaller write="yes" />
<javaversion>1.6</javaversion>
@@ -17,11 +17,12 @@
-->
<info>
<appname>MultiBit</appname>
- <appsubpath>MultiBit-0.2.0beta2</appsubpath>
- <appversion>0.2.0beta2</appversion>
+ <appsubpath>MultiBit-0.2.0beta3</appsubpath>
+ <appversion>0.2.0beta3</appversion>
<url>http://multibit.org/</url>
<uninstaller write="yes" />
<javaversion>1.6</javaversion>
+ <run-privileged condition="izpack.windowsinstall.vista|izpack.windowsinstall.7"/>
</info>
<variables>
@@ -80,7 +80,7 @@
* spent for the purposes of calculating our balance but their outputs are not available for spending yet. This
* means after a spend, our balance can actually go down temporarily before going up again!
*/
- final Map<Sha256Hash, Transaction> pending;
+ public final Map<Sha256Hash, Transaction> pending;
/**
* Map of txhash->Transactions where the Transaction has unspent outputs. These are transactions we can use
@@ -94,7 +94,7 @@
* theoretically you could spend zero-conf coins and all of them would be included together. To simplify we'll
* make people wait but it would be a good improvement to resolve this in future.
*/
- final Map<Sha256Hash, Transaction> unspent;
+ public final Map<Sha256Hash, Transaction> unspent;
/**
* Map of txhash->Transactions where the Transactions outputs are all fully spent. They are kept separately so
@@ -104,7 +104,7 @@
*
* Transactions only appear in this map if they are part of the best chain.
*/
- final Map<Sha256Hash, Transaction> spent;
+ public final Map<Sha256Hash, Transaction> spent;
/**
* An inactive transaction is one that is seen only in a block that is not a part of the best chain. We keep it
@@ -114,15 +114,15 @@
* Note that in the case where a transaction appears in both the best chain and a side chain as well, it is not
* placed in this map. It's an error for a transaction to be in both the inactive pool and unspent/spent.
*/
- private Map<Sha256Hash, Transaction> inactive;
+ public Map<Sha256Hash, Transaction> inactive;
/**
* A dead transaction is one that's been overridden by a double spend. Such a transaction is pending except it
* will never confirm and so should be presented to the user in some unique way - flashing red for example. This
* should nearly never happen in normal usage. Dead transactions can be "resurrected" by re-orgs just like any
* other. Dead transactions are not in the pending pool.
*/
- private Map<Sha256Hash, Transaction> dead;
+ public Map<Sha256Hash, Transaction> dead;
/** A list of public/private EC keys owned by this user. */
public final ArrayList<ECKey> keychain;
@@ -527,6 +527,12 @@ public void onPendingCoinsReceived(Wallet wallet, Transaction transaction) {
}
}
+ public void onReorganise(Wallet wallet) {
+ for (ViewSystem viewSystem : viewSystems) {
+ viewSystem.onReorganise(wallet);
+ }
+ }
+
public void sendCoins(PerWalletModelData perWalletModelData, String sendAddressString, String sendLabel, String amount, BigInteger fee) throws IOException,
AddressFormatException {
// send the coins
@@ -330,6 +330,7 @@ public void onPendingCoinsReceived(Wallet wallet, Transaction transaction) {
@Override
public void onReorganize(Wallet wallet) {
+ controller.onReorganise(wallet);
}
@Override
@@ -13,6 +13,7 @@
import java.nio.channels.FileChannel;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.Properties;
@@ -24,6 +25,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.Wallet;
/**
@@ -67,6 +69,17 @@ public PerWalletModelData loadFromFile(File walletFile) throws IOException {
WalletInfo walletInfo = new WalletInfo(walletFilename);
perWalletModelData.setWalletInfo(walletInfo);
+ // remove all the transactions from the wallet
+// log.info("Wallet details for wallet file before clear= " + walletFilename + "\n" + wallet.toString());
+// wallet.dead.clear();
+// wallet.inactive.clear();
+// wallet.pending.clear();
+// wallet.spent.clear();
+// wallet.unspent.clear();
+// log.info("Wallet details for wallet file after clear= " + walletFilename + "\n" + wallet.toString());
+//
+// savePerWalletModelData(perWalletModelData, false);
+
rememberFileSizesAndLastModified(walletFile, walletInfo);
perWalletModelData.setDirty(false);
@@ -85,6 +98,10 @@ public PerWalletModelData loadFromFile(File walletFile) throws IOException {
* The savePerWalletModelData is completely new
*/
public void savePerWalletModelData(PerWalletModelData perWalletModelData, boolean isNew) {
+
+// log.info("Wallet details for wallet file = " + perWalletModelData.getWalletFilename() + "\n"
+// + perWalletModelData.getWallet().toString());
+
try {
if (perWalletModelData == null) {
// nothing to do
@@ -267,7 +284,8 @@ public void writeUserPreferences() {
if ("".equals(controller.getApplicationDataDirectoryLocator().getApplicationDataDirectory())) {
userPropertiesFilename = USER_PROPERTIES_FILE_NAME;
} else {
- userPropertiesFilename = controller.getApplicationDataDirectoryLocator().getApplicationDataDirectory() + File.separator + USER_PROPERTIES_FILE_NAME;
+ userPropertiesFilename = controller.getApplicationDataDirectoryLocator().getApplicationDataDirectory()
+ + File.separator + USER_PROPERTIES_FILE_NAME;
}
outputStream = new FileOutputStream(userPropertiesFilename);
@@ -288,7 +306,8 @@ public static Properties loadUserPreferences(ApplicationDataDirectoryLocator app
if ("".equals(applicationDataDirectoryLocator.getApplicationDataDirectory())) {
userPropertiesFilename = USER_PROPERTIES_FILE_NAME;
} else {
- userPropertiesFilename = applicationDataDirectoryLocator.getApplicationDataDirectory() + File.separator + USER_PROPERTIES_FILE_NAME;
+ userPropertiesFilename = applicationDataDirectoryLocator.getApplicationDataDirectory() + File.separator
+ + USER_PROPERTIES_FILE_NAME;
}
InputStream inputStream = new FileInputStream(userPropertiesFilename);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF8");
@@ -330,56 +349,64 @@ private String createBackupFilename(File file, boolean reusePreviousBackupDate)
return backupFilename;
}
-
+
/**
- * to support multiple users on the same machine, the block chain is installed
- * into the program installation directory and is then copied to the user's
- * application data directory when MultiBit is first used
+ * to support multiple users on the same machine, the block chain is
+ * installed into the program installation directory and is then copied to
+ * the user's application data directory when MultiBit is first used
*
* thus each user has their own copy of the blockchain
*/
public void copyBlockChainFromInstallationDirectory(MultiBitService multiBitService, String destinationBlockChainFilename) {
if (destinationBlockChainFilename == null) {
return;
}
-
- // see if the block chain in the user's application data directory exists
+
+ // see if the block chain in the user's application data directory
+ // exists
// it is never overwritten
File destinationBlockchain = new File(destinationBlockChainFilename);
if (!destinationBlockchain.exists()) {
- // work out the source blockchain (put into the program installation directory by the installer)
- File directory = new File (".");
+ // work out the source blockchain (put into the program installation
+ // directory by the installer)
+ File directory = new File(".");
try {
String currentWorkingDirectory = directory.getCanonicalPath();
-
+
String filePrefix = multiBitService.getFilePrefix();
String blockchainFilename = filePrefix + MultiBitService.BLOCKCHAIN_SUFFIX;
String sourceBlockchainFilename = currentWorkingDirectory + File.separator + blockchainFilename;
File sourceBlockchain = new File(sourceBlockchainFilename);
if (sourceBlockchain.exists()) {
// it should exist since installer puts them in
- log.info("Copying blockchain from '" + sourceBlockchainFilename + "' to '" + destinationBlockChainFilename + "'");
+ log.info("Copying blockchain from '" + sourceBlockchainFilename + "' to '" + destinationBlockChainFilename
+ + "'");
long startTime = (new Date()).getTime();
copyFile(sourceBlockchain, destinationBlockchain);
long stopTime = (new Date()).getTime();
log.info("Time taken to copy blockchain was " + (stopTime - startTime) + " ms.");
-
+
// check all the data was copied
long sourceLength = sourceBlockchain.length();
long destinationLength = destinationBlockchain.length();
if (sourceLength != destinationLength) {
- log.error("Blockchain was not copied to user's application data directory correctly.\nThe source blockchain '"
- + sourceBlockchainFilename + "' is of length " + sourceLength
- + "\nbut the destination blockchain '" + destinationBlockChainFilename + "' is of length " + destinationLength);
+ log.error("Blockchain was not copied to user's application data directory correctly.\nThe source blockchain '"
+ + sourceBlockchainFilename
+ + "' is of length "
+ + sourceLength
+ + "\nbut the destination blockchain '"
+ + destinationBlockChainFilename
+ + "' is of length "
+ + destinationLength);
}
}
} catch (IOException e) {
e.printStackTrace();
- }
- }
+ }
+ }
}
-
+
public void copyFile(File sourceFile, File destinationFile) throws IOException {
if (!destinationFile.exists()) {
destinationFile.createNewFile();
@@ -97,4 +97,10 @@ public void onCoinsReceived(Wallet wallet, Transaction transaction, BigInteger p
* @param transaction
*/
public void onPendingCoinsReceived(Wallet wallet, Transaction transaction);
+
+ /**
+ * WalletEventListener callback method
+ * @param wallet
+ */
+ public void onReorganise(Wallet wallet);
}
@@ -900,6 +900,15 @@ public void onPendingCoinsReceived(Wallet wallet, Transaction transaction) {
}
}
+
+ /**
+ * one of the wallets has been reorganised due to a block chain reorganise
+ */
+ public void onReorganise(Wallet wallet) {
+ log.info("Wallet has been reorganised.");
+ recreateAllViews(true);
+ }
+
public void fireFilesHaveBeenChangedByAnotherProcess(PerWalletModelData perWalletModelData) {
if (controller.getModel().getActiveWalletFilename() != null
&& controller.getModel().getActiveWalletFilename().equals(perWalletModelData.getWalletFilename())) {
@@ -1,2 +1,2 @@
# version of multibit
-version=0.2.0beta2
+version=0.2.0beta3

0 comments on commit eda353d

Please sign in to comment.