Created
November 11, 2015 13:30
-
-
Save agran/146c4cf60ed39abaefa6 to your computer and use it in GitHub Desktop.
processTransaction speed up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void processTransaction(Transaction transaction) | |
{ | |
//CHECK IF WALLET IS OPEN | |
if(!this.exists()) | |
{ | |
return; | |
} | |
//FOR ALL ACCOUNTS | |
List<Account> accounts = this.getAccounts(); | |
List<Account> involvedAccounts = transaction.getInvolvedAccounts(); | |
synchronized(involvedAccounts) | |
{ | |
for(Account account: involvedAccounts) | |
{ | |
//CHECK IF INVOLVED | |
if(accounts.contains(account))// | |
{ | |
//System.out.println("123 " + account.getAddress()); | |
//ADD TO ACCOUNT TRANSACTIONS | |
if(!this.database.getTransactionMap().add(account, transaction)) | |
{ | |
//UPDATE UNCONFIRMED BALANCE | |
BigDecimal unconfirmedBalance = this.getUnconfirmedBalance(account.getAddress()).add(transaction.getAmount(account)); | |
this.database.getAccountMap().update(account, unconfirmedBalance); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment