Skip to content

Commit

Permalink
remove auto-stop while catchup
Browse files Browse the repository at this point in the history
  • Loading branch information
c29r3 committed Jan 13, 2021
1 parent 0a538e7 commit 276ddeb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
6 changes: 0 additions & 6 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ WORKER_PUB_KEY: YOUR_PUBLIC_KEY
# examples 0.25 MINA = 250000000 nanomina
WORKER_FEE: 0.25

# stopping snark worker during node catchup if
# current_block_height < max_observed_block_length - N
# where N is number of blocks
# if STOP_WORKER_IF_CATCHUP = 0 --> snark worker ill not be stopped
STOP_WORKER_IF_CATCHUP: 5

# how often to check `next proposal time` (seconds)
CHECK_PERIOD_SEC: 120

Expand Down
15 changes: 5 additions & 10 deletions snark-stopper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,18 @@ def parse_next_proposal_time():
current_height = daemon_status["daemonStatus"]["blockchainLength"] or 1
max_height = daemon_status["daemonStatus"]["highestBlockLengthReceived"] or 1

if sync_status.lower() != "synced" or int(current_height) < int(max_height)-STOP_WORKER_IF_CATCHUP:
if daemon_status["daemonStatus"]["snarkWorker"] is not None:
if STOP_WORKER_IF_CATCHUP > 0:
worker_manager(mode="off")
next_propos = f'😿 Node is not synced yet. STATUS: {sync_status} | Height: {current_height}\\{max_height}'
if sync_status.lower() != "synced" or int(current_height) < int(max_height)-3:
logger.fatal(f'😿 Node is not synced yet. STATUS: {sync_status} | Height: {current_height}\\{max_height}')

elif "startTime" not in str(daemon_status["daemonStatus"]["nextBlockProduction"]):
if "startTime" not in str(daemon_status["daemonStatus"]["nextBlockProduction"]):
worker_manager("on")
next_propos = "🙀 No proposal in this epoch"
else:
next_propos = int(daemon_status["daemonStatus"]["nextBlockProduction"]["times"][0]["startTime"]) / 1000
return next_propos

except Exception as parseProposalErr:
logger.exception(f'😱 parse_next_proposal_time Exception: {parseProposalErr}\n'
f'{daemon_status["daemonStatus"]["nextBlockProduction"]["times"]}')
logger.exception(f'😱 parse_next_proposal_time Exception: {parseProposalErr}')
return f'parse_next_proposal_time() Exception: {parseProposalErr}'


Expand Down Expand Up @@ -78,11 +74,10 @@ def parse_worker_pubkey():
logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='|%(asctime)s| %(message)s')
logger = logging.getLogger(__name__)
c = yaml.load(open('config.yml', encoding='utf8'), Loader=yaml.SafeLoader)
print("version 1.2.3")
print("version 1.2.4")

WORKER_PUB_KEY = str(c["WORKER_PUB_KEY"])
WORKER_FEE = float(c["WORKER_FEE"])
STOP_WORKER_IF_CATCHUP = int(c["STOP_WORKER_IF_CATCHUP"])
CHECK_PERIOD_SEC = int(c["CHECK_PERIOD_SEC"])
STOP_WORKER_FOR_MIN = int(c["STOP_WORKER_FOR_MIN"])
STOP_WORKER_BEFORE_MIN = int(c["STOP_WORKER_BEFORE_MIN"])
Expand Down

0 comments on commit 276ddeb

Please sign in to comment.