Skip to content

Commit

Permalink
Added new command get_nodes_count which acts the same way as coin_count
Browse files Browse the repository at this point in the history
  • Loading branch information
Max00355 committed Nov 28, 2013
1 parent d4213d7 commit 4f0c5de
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

relay = 0
brokers = [{"ip":"zcoin.zapto.org", "port":6564}]
version = "0.2.0"
version = "0.2.1"
host = "0.0.0.0"
port = 6565
nodes = landerdb.Connect("nodes.db")
Expand Down
21 changes: 21 additions & 0 deletions get_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
import random
import os
import time
import send_command

def count_send():
mine = config.nodes.find("nodes", "all")
if not mine:
mine = 0
else:
mine = len(mine)
print mine
check = send_command.send({"cmd":"get_nodes_count"}, out=True)
check = json.loads(check)
if check['nodes'] > mine:
send()

def count(obj, data):
co = config.nodes.find("nodes", "all")
if not co:
co = 0
else:
co = len(co)
obj.send(json.dumps({"nodes":co}))

def get_nodes(obj, data):
with open("nodes.db", 'rb') as file:
Expand Down
4 changes: 2 additions & 2 deletions zcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def __init__(self):
"get_difficulty":get_difficulty.get_difficulty,
"check_coin":check_coin.check_coin,
"send_coin":send_coin.send_coin,
"get_nodes_count":get_nodes.count,
}

def firstrun(self):
Expand Down Expand Up @@ -85,8 +86,7 @@ def normal(self):
register.send()
while True:
coin_count.send()
if not config.relay:
get_nodes.send()
get_nodes.count_send()
time.sleep(60)
if __name__ == "__main__":
zc = zCoin()
Expand Down

0 comments on commit 4f0c5de

Please sign in to comment.