I have a java web application. When ever a user signup i create a wallet 
for them. I use the below code to create wallet for user and put that 
wallet object in Map<String,Wallet>.

/**
 * This is the global map that maintain wallet across application. When ever
 * i have to get balance or make transaction i use wallet object in the map.
 * 
 * The main reason for doing this is that Wallet object in map will always
 * be in synchronization with the blockchain
 */
Map<String, Wallet> applicationWalletMap = new HashMap<String, Wallet>();


 public void createWalletForUser() throws IOException{
 int bits = 128;
 SecureRandom random = new SecureRandom();
 DeterministicKeyChain determinstickeychain = new DeterministicKeyChain(
random, bits);
 DeterministicSeed seed = determinstickeychain.getSeed();
 System.out.println("seed " + seed.getSeedBytes());
 Wallet wallet = Wallet.fromSeed(TestNet3Params.get(), seed);
 ECKey eckey = new ECKey();
 wallet.importKey(eckey);
 String fileName = UUID.randomUUID().toString();
 wallet.saveToFile(new File("/opt/"+fileName+".dat"));
 System.out.println("Wallet has been created");
 applicationWalletMap.put(fileName, wallet);
 } 



Also I put all user's synchronized wallet object in *applicationWalletMap *when 
i start web application. 

The issue is that when user keep on increasing the size of 
*applicationWalletMap 
*increases. *This consumes a lot of RAM*. So is there is any efficient way 
to handle this problem.

Thanks in advance

-- 
You received this message because you are subscribed to the Google Groups 
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bitcoinj+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to