mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-11-12 08:29:16 +00:00
Only get latest block data if new block is found
This commit is contained in:
parent
178d05254a
commit
982dd407d5
|
@ -11,6 +11,7 @@ bitcoin_block_height = 570000
|
|||
mynode_block_height = 566000
|
||||
bitcoin_blockchain_info = None
|
||||
bitcoin_recent_blocks = None
|
||||
bitcoin_recent_blocks_last_cache_height = 566000
|
||||
bitcoin_peers = []
|
||||
bitcoin_network_info = None
|
||||
bitcoin_wallet_info = None
|
||||
|
@ -63,8 +64,10 @@ def update_bitcoin_main_info():
|
|||
return True
|
||||
|
||||
def update_bitcoin_other_info():
|
||||
global mynode_block_height
|
||||
global bitcoin_blockchain_info
|
||||
global bitcoin_recent_blocks
|
||||
global bitcoin_recent_blocks_last_cache_height
|
||||
global bitcoin_peers
|
||||
global bitcoin_network_info
|
||||
global bitcoin_mempool
|
||||
|
@ -84,9 +87,11 @@ def update_bitcoin_other_info():
|
|||
# Get other less important info
|
||||
try:
|
||||
# Recent blocks
|
||||
if mynode_block_height != bitcoin_recent_blocks_last_cache_height:
|
||||
commands = [ [ "getblockhash", height] for height in range(mynode_block_height-9, mynode_block_height+1) ]
|
||||
block_hashes = rpc_connection.batch_(commands)
|
||||
bitcoin_recent_blocks = rpc_connection.batch_([ [ "getblock", h ] for h in block_hashes ])
|
||||
bitcoin_recent_blocks_last_cache_height = mynode_block_height
|
||||
|
||||
# Get peers
|
||||
bitcoin_peers = rpc_connection.getpeerinfo()
|
||||
|
|
Loading…
Reference in New Issue
Block a user