Why does Multichaind process crash while fetching huge number of transactions?

0 votes

I'm using a JSON RPC API to communicate with my private blockchain. When I fetch a huge number of transactions (let's say 20000) from the Blockchain using the command listwallettransactions, I noticed that the multichaind process crashes. It happened everytime I triggered the call. Is it because of the hardware capacity of the server, or any other reason?

Note: The size of each user initiated transaction is around 370 bytes, and each mining related transaction is around 200-300 bytes.

I'm using a server with the following specifications from digital ocean:

512 MB Memory
1 CoreProcessor
20 GB SSD Disk
1TB Transfer

asked Apr 20, 2016 by Cypher

1 Answer

0 votes
 
Best answer

listwallettransactions command provides a feature comparable to a select * type of sql query in database ex: Mysql. If the number of transactions are high, it would have a toll on the hardware resource of the underlying system as the buffer required would shoot up. I see this as a general issue which exists in Blockchain and non blockchain systems like a database. In general, in normal systems we tend to provide a limit to the query or provide a count. In the similar fashion, in my opinion I would suggest you to  leverage the count and skip model provided by the command api. Now assuming you have 20000 transactions, we can divide the execution to 100 commands for ex:

multichain-cli chain1 listwallettransactions 100 0

multichain-cli chain1 listwallettransactions 100 100

multichain-cli chain1 listwallettransactions 100 200

....

whenever you get an json array response whose size it less than 100, we can stop the loop.


Also by using the command getwalletinfo, we can get the number of total transactions in the wallet at current time: (This could be used to pre-determine the loop)

For example:

{"method":"getwalletinfo","params":[],"id":1,"chain_name":"chain1"}

{
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "txcount" : 153, 
    "keypoololdest" : 1461150513,
    "keypoolsize" : 2
}

Considering the txcount as 153 we can use:

multichain-cli chain1 listwallettransactions 100 0

multichain-cli chain1 listwallettransactions 53 100 or multichain-cli chain1 listwallettransactions 100 100 (The json array response size shall be 53)


Now considering the hardware specs, even if the specs are enhanced, with increase in the number of transactions, the limitations will come. Hence I will think you should be using the count and skip mode.

answered Apr 21, 2016 by 7sigma
selected Apr 21, 2016 by Cypher
Thank you. Is there any api command which outputs the total number of transactions for an address? For ex., the getwalletinfo command displays the total number of wallet transactions in the output.
...