Skip to content
Snippets Groups Projects
Commit c9556140 authored by Anthony Martin's avatar Anthony Martin
Browse files

backfill signals #165

parent 910179ae
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ from . import util
ACTIONS_MAJOR_VERSION_SUPPORTED = 0
ACTIONS_MINOR_VERSION_SUPPORTED = 2
STEEM_BLOCK_INTERVAL = 3
class TransactionSigner(object):
def __init__(self, sign_transaction_exe=None, chain_id=None):
......@@ -168,19 +169,30 @@ def main(argv):
try:
if cmd == "metadata":
metadata = args
transactions_per_block = metadata.get("txgen:transactions_per_block", transactions_per_block)
semver = metadata.get("txgen:semver", '0.0')
major_version, minor_version = semver.split('.')
major_version = int(major_version)
minor_version = int(minor_version)
if major_version == ACTIONS_MAJOR_VERSION_SUPPORTED:
print("metadata:", metadata)
else:
raise RuntimeError("Unsupported actions:", metadata)
if args.get("post_backfill"):
dgpo = cached_dgpo.get()
now = datetime.datetime.utcnow()
head_block_time = datetime.datetime.strptime(dgpo["time"], "%Y-%m-%dT%H:%M:%S")
join_head = int((now - head_block_time).total_seconds()) // STEEM_BLOCK_INTERVAL
if minor_version < ACTIONS_MINOR_VERSION_SUPPORTED:
print("WARNING: Older actions encountered.", file=sys.stderr)
if join_head > STEEM_BLOCK_INTERVAL:
generate_blocks(steemd, {"count": join_head}, cached_dgpo=cached_dgpo, produce_realtime=produce_realtime)
cached_dgpo.reset()
else:
transactions_per_block = metadata.get("txgen:transactions_per_block", transactions_per_block)
semver = metadata.get("txgen:semver", '0.0')
major_version, minor_version = semver.split('.')
major_version = int(major_version)
minor_version = int(minor_version)
if major_version == ACTIONS_MAJOR_VERSION_SUPPORTED:
print("metadata:", metadata)
else:
raise RuntimeError("Unsupported actions:", metadata)
if minor_version < ACTIONS_MINOR_VERSION_SUPPORTED:
print("WARNING: Older actions encountered.", file=sys.stderr)
elif cmd == "wait_blocks":
if metadata and args.get("count") == 1 and args.get("miss_blocks"):
if args["miss_blocks"] < metadata["recommend:miss_blocks"]:
......
......@@ -30,6 +30,7 @@ NUM_BLOCKS_TO_CLEAR_WITNESS_ROUND = 21
TRANSACTION_WITNESS_SETUP_PAD = 100
STEEM_MAX_AUTHORITY_MEMBERSHIP = 10
DENOM = 10**12 # we need stupidly high precision because VESTS
STEEM_BLOCKS_PER_DAY = 28800
def create_system_accounts(conf, keydb, name):
desc = conf["accounts"][name]
......@@ -431,6 +432,8 @@ def build_actions(conf, silent=True):
if num_lines > 0:
metadata["backfill_actions:count"] = num_lines
metadata["actions:count"] += num_lines
miss_blocks -= max(num_lines // transactions_per_block, STEEM_BLOCKS_PER_DAY * 30)
metadata["recommend:miss_blocks"] = miss_blocks
has_backfill = True
yield ["metadata", metadata]
......@@ -444,6 +447,8 @@ def build_actions(conf, silent=True):
with open(backfill_file, "r") as f:
for line in f:
yield json.loads(line)
yield ["metadata", {"post_backfill" : True}]
for tx in update_witnesses(conf, keydb, "init"):
yield ["submit_transaction", {"tx" : tx}]
......
......@@ -130,7 +130,7 @@ def action_to_str(action):
This serializes actions, picking a string that does not occur in the JSON
serialization to escape public/private key notes.
"""
if "esc" in action:
if action and action[1] and "esc" in action[1]:
return json.dumps(action, separators=(",", ":"), sort_keys=True)
json_empty_esc = json.dumps(action, separators=(",", ":"), default=prockey.PubkeySerializer(esc=""), sort_keys=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment