Skip to content

Commit

Permalink
Add dry_run support to transaction broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
emre committed Oct 11, 2018
1 parent 5754f03 commit 6492045
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lightsteem/broadcast/transaction_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def _is_canonical(self, sig):
and not (sig[32] & 0x80)
and not (sig[32] == 0 and not (sig[33] & 0x80)))

def broadcast(self, operations, chain=None):
def broadcast(self, operations, chain=None, dry_run=False):
preferred_api_type = self.client.api_type
if not isinstance(operations, list):
operations = [operations, ]

Expand Down Expand Up @@ -192,5 +193,9 @@ def broadcast(self, operations, chain=None):
sigs.append(hexlify(sigstr).decode('ascii'))

self.transaction["signatures"] = sigs
self.client.api_type = preferred_api_type

if dry_run:
return self.transaction

return self.client.broadcast_transaction(self.transaction)
5 changes: 3 additions & 2 deletions lightsteem/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,9 @@ def process_batch(self):
self.queue = []
return resp

def broadcast(self, op):
return self.transaction_builder.broadcast(op, chain=self.chain)
def broadcast(self, op, dry_run=False):
return self.transaction_builder.broadcast(
op, chain=self.chain, dry_run=dry_run)

def account(self, username):
return Account(self, username)

0 comments on commit 6492045

Please sign in to comment.