Skip to content

Commit

Permalink
updated switch.py to check witness shuffle, and if witness is within …
Browse files Browse the repository at this point in the history
…last 5 witness slots to not switch signing keys when a block is missed
  • Loading branch information
gileadmcgee committed Nov 5, 2015
1 parent 4a88252 commit ff83441
Show file tree
Hide file tree
Showing 39 changed files with 25 additions and 774 deletions.
637 changes: 0 additions & 637 deletions scripts/pricefeeds/pricefeeds.py

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/switch-keys/config-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# the name of your witness as string
witnessname = "test.dele-puppy"

# witness number
witness_object = "1.6.13"
# the password of your wallet as string
wallet_password = "puppiesRkewl" # not really my password. Just left in so people can see how it should look.

Expand Down
73 changes: 0 additions & 73 deletions scripts/switch-keys/example-config.ini

This file was deleted.

Binary file removed scripts/switch-keys/object_database/1/10
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/11
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/12
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/13
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/14
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/15
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/2
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/3
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/4
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/5
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/6
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/7
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/1/8
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/0
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/1
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/10
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/11
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/12
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/13
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/3
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/4
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/5
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/6
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/7
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/8
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/2/9
Binary file not shown.
Binary file removed scripts/switch-keys/object_database/5/1
Binary file not shown.
Empty file.
13 changes: 0 additions & 13 deletions scripts/switch-keys/producer1/config-example.py

This file was deleted.

8 changes: 4 additions & 4 deletions scripts/switch-keys/producer1/producer1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def tryProducer():
while attempt < 5:
attempt +=1
print("attempt #" + attempt + " to reconnect to " + wallet_name)
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
time.sleep(1)


Expand All @@ -47,8 +47,8 @@ def openProducer():

try:
print("waiting ...")
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
time.sleep(1)
checkIfNew()
unlockWallet()
Expand Down
Empty file.
13 changes: 0 additions & 13 deletions scripts/switch-keys/producer2/config-example.py

This file was deleted.

13 changes: 0 additions & 13 deletions scripts/switch-keys/producer2/config2.py

This file was deleted.

8 changes: 4 additions & 4 deletions scripts/switch-keys/producer2/producer2.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def tryProducer():
while attempt < 5:
attempt +=1
print("attempt #" + attempt + " to reconnect to " + wallet_name)
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
time.sleep(1)


Expand All @@ -48,8 +48,8 @@ def openProducer():

try:
print("waiting ...")
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"--chain-id","16362d305df19018476052eed629bb4052903c7655a586a0e0cfbdb0eaf1bfd8"]) ### uncomment this line if running on testnet
# subprocess.call(["screen","-dmS",wallet_name,path_to_cli_wallet,"-H",local_port,"-s",remote_ws,"]) ### comment this line out if running on testnet
time.sleep(1)
checkIfNew()
unlockWallet()
Expand Down
19 changes: 15 additions & 4 deletions scripts/switch-keys/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
from producer2 import producer2




# (note to self I would like to add a check if the current block age is greater than or less than a minute to participation check. If head_block_age is greater than 1 min, it is possible it is syncing the blockchain, and we should wait 15 or so seconds, do a second check and then resplay if needed.)
#
#
rpc = GrapheneWebsocket("localhost", 8092, "", "")

def unlockWallet():
Expand Down Expand Up @@ -58,7 +59,7 @@ def info():
return part

def waitAndNotify():
time.sleep(3)
time.sleep(1)
info = rpc.info()
block = info["head_block_num"]
age = info["head_block_age"]
Expand Down Expand Up @@ -160,7 +161,16 @@ def getMissed(witnessname):

# add check for age of head block, and last block vs head block
def switch(witnessname, publickeys, missed):
if config.switching_active == True:
shuffle = rpc.get_object("2.12.0")
shuffle = shuffle["current_shuffled_witnesses"]
witness1 = shuffle[len(shuffle) -1]
witness2 = shuffle[len(shuffle) -2]
witness3 = shuffle[len(shuffle) -3]
witness4 = shuffle[len(shuffle) -4]
witness5 = shuffle[len(shuffle) -5]
if config.witness_object == witness1 or config.witness_object == witness2 or config.witness_object == witness3 or config.witness_object == witness4 or config.witness_object == witness5:
return
elif config.switching_active == True:
blockAge = rpc.info()
blockAge = blockAge["head_block_age"]
blockAgeInt = int(blockAge.split()[0])
Expand All @@ -171,6 +181,7 @@ def switch(witnessname, publickeys, missed):
key = publickeys[keynumber]
rpc.update_witness(witnessname, "", key, "true")
print("updated signing key to " + key)
time.sleep(3)

feed = True
replay = 0
Expand Down
13 changes: 0 additions & 13 deletions scripts/switch-keys/wallet.json

This file was deleted.

0 comments on commit ff83441

Please sign in to comment.