提交 52aa8b67 编写于 作者: B Brian Johnson

Added printing out transaction information after Node commands that create...

Added printing out transaction information after Node commands that create transactions to provide traceability for missing transactions. GH #5674
上级 f72ee37c
......@@ -140,10 +140,18 @@ class Node(object):
assert trans
assert isinstance(trans, dict), print("Input type is %s" % type(trans))
#Utils.Print("%s" % trans)
assert "transaction_id" in trans, print("trans does not contain key %s. trans={%s}" % ("transaction_id", json.dumps(trans, indent=2, sort_keys=True)))
transId=trans["transaction_id"]
return transId
@staticmethod
def isTrans(obj):
"""Identify if this is a transaction dictionary."""
if obj is None or not isinstance(obj, dict):
return False
return True if "transaction_id" in obj else False
@staticmethod
def byteArrToStr(arr):
return arr.decode("utf-8")
......@@ -205,6 +213,7 @@ class Node(object):
if Utils.Debug: Utils.Print("cmd: echo '%s' | %s" % (subcommand, cmd))
try:
trans=Node.runMongoCmdReturnJson(cmd.split(), subcommand)
Node.logCmdTransaction(trans)
if trans is not None:
return trans
except subprocess.CalledProcessError as ex:
......@@ -466,6 +475,7 @@ class Node(object):
account.activePublicKey, stakeNet, CORE_SYMBOL, stakeCPU, CORE_SYMBOL, buyRAM, CORE_SYMBOL)
msg="(creator account=%s, account=%s)" % (creatorAccount.name, account.name);
trans=self.processCleosCmd(cmd, cmdDesc, silentErrors=False, exitOnError=exitOnError, exitMsg=msg)
Node.logCmdTransaction(trans)
transId=Node.getTransId(trans)
if stakedDeposit > 0:
......@@ -483,11 +493,13 @@ class Node(object):
cmdDesc, creatorAccount.name, account.name, account.ownerPublicKey, account.activePublicKey)
msg="(creator account=%s, account=%s)" % (creatorAccount.name, account.name);
trans=self.processCleosCmd(cmd, cmdDesc, silentErrors=False, exitOnError=exitOnError, exitMsg=msg)
Node.logCmdTransaction(trans)
transId=Node.getTransId(trans)
if stakedDeposit > 0:
self.waitForTransInBlock(transId) # seems like account creation needs to be finlized before transfer can happen
trans = self.transferFunds(creatorAccount, account, "%0.04f %s" % (stakedDeposit/10000, CORE_SYMBOL), "init")
Node.logCmdTransaction(trans)
transId=Node.getTransId(trans)
return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)
......@@ -638,6 +650,7 @@ class Node(object):
trans=None
try:
trans=Utils.runCmdArrReturnJson(cmdArr)
Node.logCmdTransaction(trans)
except subprocess.CalledProcessError as ex:
msg=ex.output.decode("utf-8")
Utils.Print("ERROR: Exception during funds transfer. %s" % (msg))
......@@ -819,6 +832,7 @@ class Node(object):
trans=None
try:
trans=Utils.runCmdReturnJson(cmd, trace=False)
Node.logCmdTransaction(trans)
except subprocess.CalledProcessError as ex:
if not shouldFail:
msg=ex.output.decode("utf-8")
......@@ -876,6 +890,7 @@ class Node(object):
if Utils.Debug: Utils.Print("cmd: %s" % (cmdArr))
try:
trans=Utils.runCmdArrReturnJson(cmdArr)
Node.logCmdTransaction(trans, ignoreNonTrans=True)
return (True, trans)
except subprocess.CalledProcessError as ex:
msg=ex.output.decode("utf-8")
......@@ -887,6 +902,7 @@ class Node(object):
cmdDesc="set action permission"
cmd="%s -j %s %s %s %s" % (cmdDesc, account, code, pType, requirement)
trans=self.processCleosCmd(cmd, cmdDesc, silentErrors=False, exitOnError=exitOnError)
Node.logCmdTransaction(trans)
return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)
......@@ -900,6 +916,7 @@ class Node(object):
cmdDesc, fromAccount.name, toAccount.name, netQuantity, CORE_SYMBOL, cpuQuantity, CORE_SYMBOL, transferStr)
msg="fromAccount=%s, toAccount=%s" % (fromAccount.name, toAccount.name);
trans=self.processCleosCmd(cmd, cmdDesc, exitOnError=exitOnError, exitMsg=msg)
Node.logCmdTransaction(trans)
return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)
......@@ -909,6 +926,7 @@ class Node(object):
cmdDesc, producer.name, producer.activePublicKey, url, location)
msg="producer=%s" % (producer.name);
trans=self.processCleosCmd(cmd, cmdDesc, exitOnError=exitOnError, exitMsg=msg)
Node.logCmdTransaction(trans)
return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)
......@@ -918,6 +936,7 @@ class Node(object):
cmdDesc, account.name, " ".join(producers))
msg="account=%s, producers=[ %s ]" % (account.name, ", ".join(producers));
trans=self.processCleosCmd(cmd, cmdDesc, exitOnError=exitOnError, exitMsg=msg)
Node.logCmdTransaction(trans)
return self.waitForTransBlockIfNeeded(trans, waitForTransBlock, exitOnError=exitOnError)
......@@ -967,6 +986,7 @@ class Node(object):
try:
if returnType==ReturnType.json:
trans=Utils.runCmdReturnJson(cmd, silentErrors=silentErrors)
Node.logCmdTransaction(trans)
elif returnType==ReturnType.raw:
trans=Utils.runCmdReturnStr(cmd)
else:
......@@ -1227,6 +1247,20 @@ class Node(object):
self.killed=False
return True
@staticmethod
def logCmdTransaction(trans, ignoreNonTrans=False):
if not Utils.Debug:
return
if trans is None:
Utils.Print(" cmd returned transaction: %s" % (trans))
if ignoreNonTrans and not Node.isTrans(trans):
return
transId=Node.getTransId(trans)
Utils.Print(" cmd returned transaction id: %s" % (transId))
def reportStatus(self):
Utils.Print("Node State:")
Utils.Print(" cmd : %s" % (self.cmd))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册