Skip to content

Instantly share code, notes, and snippets.

@xeroc
Created June 23, 2020 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xeroc/62fed997b7f90f392709eb943e34e4c2 to your computer and use it in GitHub Desktop.
Save xeroc/62fed997b7f90f392709eb943e34e4c2 to your computer and use it in GitHub Desktop.
if not self.worker.blockchain.nobroadcast:
# We using blocking so after this call we can be sure the operation
# is on the blockchain. However, a transfer does not return a
# resulting operation id as no object is created, thus we go thru
# the history and obtain the most recent operation id
# FIXME: potentially, this could go wrong in case some other entity
# has access ot the accounting account too and leverages that at the
# very same time. The ids would still be close to each other
account = Account(self.accounting_account)
statistics = Object(account["statistics"])
most_recent_op = Object(statistics["most_recent_op"])
op_id = most_recent_op["operation_id"]
log.info("operation ID: {}".format(op_id))
# Store transaction
bill.operation_id = op_id
db.session.commit()
db.session.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment