Bitcoin Forum
May 27, 2024, 10:32:35 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin rpc gradually slows down  (Read 101 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: 1610
Merit: 6813


bitcoincleanup.com / bitmixlist.org


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 (?)

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
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: 4316

<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: 2422
Merit: 5650


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!