Bitcoin Forum
November 06, 2024, 02:20:00 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin rpc gradually slows down  (Read 120 times)
linuxqq (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 6


View Profile
April 17, 2021, 08: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。
NotATether
Legendary
*
Offline Offline

Activity: 1778
Merit: 7362


Top Crypto Casino


View Profile WWW
April 17, 2021, 08: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 (?)

███████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████

███████████████████████
.
BC.GAME
▄▄▀▀▀▀▀▀▀▄▄
▄▀▀░▄██▀░▀██▄░▀▀▄
▄▀░▐▀▄░▀░░▀░░▀░▄▀▌░▀▄
▄▀▄█▐░▀▄▀▀▀▀▀▄▀░▌█▄▀▄
▄▀░▀░░█░▄███████▄░█░░▀░▀▄
█░█░▀░█████████████░▀░█░█
█░██░▀█▀▀█▄▄█▀▀█▀░██░█
█░█▀██░█▀▀██▀▀█░██▀█░█
▀▄▀██░░░▀▀▄▌▐▄▀▀░░░██▀▄▀
▀▄▀██░░▄░▀▄█▄▀░▄░░██▀▄▀
▀▄░▀█░▄▄▄░▀░▄▄▄░█▀░▄▀
▀▄▄▀▀███▄███▀▀▄▄▀
██████▄▄▄▄▄▄▄██████
.
..CASINO....SPORTS....RACING..


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
linuxqq (OP)
Jr. Member
*
Offline Offline

Activity: 34
Merit: 6


View Profile
April 17, 2021, 08: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
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4361

<insert witty quote here>


View Profile
April 17, 2021, 11:46:02 PM
Merited by Quickseller (2)
 #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.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
nc50lc
Legendary
*
Offline Offline

Activity: 2590
Merit: 6332


Self-proclaimed Genius


View Profile
April 18, 2021, 04: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/

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!