From af19e973beefafab31d742c93b5554cfcd4dda3e Mon Sep 17 00:00:00 2001 From: D4708 Date: Sat, 26 Jun 2021 16:11:12 +0300 Subject: [PATCH] add blocks per step limit --- follower.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/follower.py b/follower.py index ca46cc6..5bb38ba 100644 --- a/follower.py +++ b/follower.py @@ -13,6 +13,7 @@ import sys, cPickle dbFileName = "twisterDataGuard.pickle" nodeUserName = "twisterdataguard" +blocksInStep = 10000 try: from bitcoinrpc.authproxy import AuthServiceProxy @@ -39,11 +40,17 @@ except: print "blockchain reading..." while True: + block = twister.getblock(nextHash) db.lastBlockHash = block["hash"] - print "block", str(block["height"]) + "\r", - usernames = block["usernames"] - for u in usernames: + + blocksInStep = blocksInStep - 1 + if blocksInStep < 0: + break + + print "read block", str(block["height"]) + "\r", + + for u in block["usernames"]: print "follow", u twister.follow(nodeUserName, [u]) if block.has_key("nextblockhash"):