From e994fb319a5195f3bdb6baef257ebb947befbe76 Mon Sep 17 00:00:00 2001 From: Jude Nelson Date: Fri, 13 Apr 2018 19:17:06 -0400 Subject: [PATCH] commit vesting at block_height+1 at the end of the block, so vested tokens are immediately usable. Also, expand the set of acceptable operations to include token operations --- blockstack/lib/nameset/virtualchain_hooks.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/blockstack/lib/nameset/virtualchain_hooks.py b/blockstack/lib/nameset/virtualchain_hooks.py index a6faf4a5d..f56ec89fe 100644 --- a/blockstack/lib/nameset/virtualchain_hooks.py +++ b/blockstack/lib/nameset/virtualchain_hooks.py @@ -422,7 +422,7 @@ def db_commit( block_id, op, op_data, txid, vtxindex, db_state=None ): assert op_data['vtxindex'] == vtxindex, "BUG: vtxindex mismatch" opcode = op_data.get('opcode', None) - assert opcode in OPCODE_PREORDER_OPS + OPCODE_CREATION_OPS + OPCODE_TRANSITION_OPS + OPCODE_STATELESS_OPS, \ + assert opcode in OPCODE_PREORDER_OPS + OPCODE_CREATION_OPS + OPCODE_TRANSITION_OPS + OPCODE_STATELESS_OPS + OPCODE_TOKEN_OPS, \ "BUG: uncategorized opcode '%s'" % opcode except Exception, e: @@ -475,17 +475,17 @@ def db_save( block_height, consensus_hash, ops_hash, accepted_ops, virtualchain_ blockstack_opts = get_blockstack_opts() new_zonefile_infos = None - # vest any tokens + # vest any tokens for the next block (so they'll be immediately usable in the next block) try: - db_state.commit_account_vesting(block_height) + db_state.commit_account_vesting(block_height+1) except Exception as e: log.exception(e) - log.fatal("Failed to vest accounts at {}".format(block_height)) + log.fatal("Failed to vest accounts at {}+1".format(block_height)) os.abort() try: # flush the database - db_state.commit_finished( block_height ) + db_state.commit_finished(block_height) except Exception as e: log.exception(e) log.error("FATAL: failed to commit at block %s" % block_height )