Author

Topic: Bitcoin rpc gradually slows down (Read 115 times)

legendary
Activity: 2534
Merit: 6080
Self-proclaimed Genius
April 18, 2021, 12:02:32 AM
#5
I try to keep querying the transactions of some blocks, but the time return time will gradually return from 6 seconds to 30 seconds, getting slower and slower
Are you looking at some specific blocks? If there's only a few, you should get their blockhash and use that as an additional parameter for getrawtransaction.
That should speed things up.

https://bitcoincore.org/en/doc/0.21.0/rpc/rawtransactions/getrawtransaction/
HCP
legendary
Activity: 2086
Merit: 4318
April 17, 2021, 07:46:02 PM
#4
Does the return time increase if you request the same block over and over? or is it increasing for a specific "set" of blocks?

If there is a particular block or blocks where it always takes a long time, have you checked those blocks manually to see if there are any attributes of the blocks that might cause the slowdown? ie. transactions with large number of outputs or transactions with large number of inputs etc.

it's also possible that your node is throttling your RPC connection because you're making repeated calls to getrawtransaction... I've never experienced that myself, but I've never had a script that has the potential to make repeated calls over and over either.
jr. member
Activity: 34
Merit: 6
April 17, 2021, 04:41:23 AM
#3
Code:
    
           for vin in raw_tx[u'vin']:  
                if "coinbase" in vin:
                    continue
                if ("txid" not in vin):
                    continue
                voutid = vin["vout"]
                while True:
                    try:
                        tx_out = self.ConnRpc.getrawtransaction(vin["txid"], True)
                        vout = tx_out[u'vout'][voutid]
                        break
                    except:
                        self.connect()
                        sleep(0.1)
                if "scriptPubKey" not in vout:
                    pass

                if vout["scriptPubKey"]["type"] == "nulldata":
                    pass
                elif "addresses" in vout['scriptPubKey']:
                    outaddr = vout['scriptPubKey']['addresses'][0]
                    if outaddr not in address:
                        address[outaddr] = -1 * float(vout["value"])
                    else:
                        address[outaddr] += -1 * float(vout["value"])
                else:
                    pass


I try to keep querying the transactions of some blocks, but the time return time will gradually return from 6 seconds to 30 seconds, getting slower and slower
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
April 17, 2021, 04:30:09 AM
#2
Exactly how long are we talking in terms of seconds, and how much more does your waiting time increase?  Do you have -txindex on and you're trying to get a block transaction? I never heard of that directly causing a slow response but it's understandable if the block it's inside hasn't been processed by Core yet.

If you're trying to get a mempool transaction from your node, it might be because your node doesn't have the transaction locally (?)
jr. member
Activity: 34
Merit: 6
April 17, 2021, 04:18:59 AM
#1
I use python3 to call the getrawtransaction interface of bitcoin rpc. Why does the query return time take longer and longer? The system load and disk IO are not too high load。
Jump to: