forked from mathieulavoie/Bitcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_money.py
46 lines (34 loc) · 1.37 KB
/
map_money.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import sys
from crawler.money_crawler import MoneyCrawler
from settings import settings
def start(start_block_id, end_block_id):
mapper = MoneyCrawler()
block_id = start_block_id
try:
while block_id <= end_block_id and mapper.crawl_block(block_id):
if settings.debug or block_id %100 == 0:
print("Money of Block %d mapped" % block_id)
if block_id - start_block_id > 0 and (block_id - start_block_id) % settings.block_crawling_limit == 0:
mapper.insert_into_db()
mapper.money_movements = []
mapper.cache_nodeid_addresses = dict()
mapper.connect_to_bitcoind_rpc()
block_id+=1
#Sync the rest
print("Inserting the last records in the DB")
mapper.insert_into_db()
print("Ensure that indexes are created")
mapper.ensure_indexes()
print("Done!")
mapper.client.close()
#DONE!
#For Debugging purpose
except:
input("An exception will rise ")
raise
if __name__ == "__main__":
mapper = MoneyCrawler()
if len(sys.argv) == 3 :
start(int(sys.argv[1]), int(sys.argv[2]))
else:
print("Usage: python %s <starting block id> <ending block id>" % sys.argv[0])