|
|
|
@ -13,7 +13,11 @@ import sys, cPickle
@@ -13,7 +13,11 @@ import sys, cPickle
|
|
|
|
|
|
|
|
|
|
dbFileName = "twisterDataGuard.pickle" |
|
|
|
|
nodeUserName = "twisterdataguard" |
|
|
|
|
blocksInStep = 10000 |
|
|
|
|
blocksInStep = 10 |
|
|
|
|
|
|
|
|
|
class MyDb: |
|
|
|
|
lastBlockHash = 0 |
|
|
|
|
dataLock = False |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
from bitcoinrpc.authproxy import AuthServiceProxy |
|
|
|
@ -27,15 +31,19 @@ if len(sys.argv) > 1:
@@ -27,15 +31,19 @@ if len(sys.argv) > 1:
|
|
|
|
|
|
|
|
|
|
twister = AuthServiceProxy(serverUrl) |
|
|
|
|
|
|
|
|
|
class MyDb: |
|
|
|
|
lastBlockHash = 0 |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
db = cPickle.load(open(dbFileName)) |
|
|
|
|
nextHash = db.lastBlockHash |
|
|
|
|
dataLock = db.dataLock |
|
|
|
|
except: |
|
|
|
|
db = MyDb() |
|
|
|
|
nextHash = twister.getblockhash(0) |
|
|
|
|
dataLock = db.dataLock |
|
|
|
|
|
|
|
|
|
if not dataLock: |
|
|
|
|
|
|
|
|
|
db.dataLock = True |
|
|
|
|
cPickle.dump(db, open(dbFileName, "w")) |
|
|
|
|
|
|
|
|
|
print "blockchain reading..." |
|
|
|
|
|
|
|
|
@ -46,6 +54,7 @@ while True:
@@ -46,6 +54,7 @@ while True:
|
|
|
|
|
|
|
|
|
|
blocksInStep = blocksInStep - 1 |
|
|
|
|
if blocksInStep < 0: |
|
|
|
|
db.dataLock = False |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
print "read block", str(block["height"])# + "\r", |
|
|
|
@ -61,3 +70,6 @@ while True:
@@ -61,3 +70,6 @@ while True:
|
|
|
|
|
cPickle.dump(db, open(dbFileName, "w")) |
|
|
|
|
|
|
|
|
|
print "task completed." |
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
print "operation locked by the running process." |
|
|
|
|