本文整理汇总了Python中Node.Node.setWalletEndpointArgs方法的典型用法代码示例。如果您正苦于以下问题:Python Node.setWalletEndpointArgs方法的具体用法?Python Node.setWalletEndpointArgs怎么用?Python Node.setWalletEndpointArgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.setWalletEndpointArgs方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initializeNodesFromJson
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import setWalletEndpointArgs [as 别名]
def initializeNodesFromJson(self, nodesJsonStr):
nodesObj= json.loads(nodesJsonStr)
if nodesObj is None:
Utils.Print("ERROR: Invalid Json string.")
return False
if "keys" in nodesObj:
keysMap=nodesObj["keys"]
if "defproduceraPrivateKey" in keysMap:
defproduceraPrivateKey=keysMap["defproduceraPrivateKey"]
self.defproduceraAccount.ownerPrivateKey=defproduceraPrivateKey
if "defproducerbPrivateKey" in keysMap:
defproducerbPrivateKey=keysMap["defproducerbPrivateKey"]
self.defproducerbAccount.ownerPrivateKey=defproducerbPrivateKey
nArr=nodesObj["nodes"]
nodes=[]
for n in nArr:
port=n["port"]
host=n["host"]
node=Node(host, port)
node.setWalletEndpointArgs(self.walletEndpointArgs)
if Utils.Debug: Utils.Print("Node:", node)
node.checkPulse()
nodes.append(node)
self.nodes=nodes
return True
示例2: initializeNodes
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import setWalletEndpointArgs [as 别名]
def initializeNodes(self, defproduceraPrvtKey=None, defproducerbPrvtKey=None, onlyBios=False):
port=Cluster.__BiosPort if onlyBios else self.port
host=Cluster.__BiosHost if onlyBios else self.host
node=Node(host, port, enableMongo=self.enableMongo, mongoHost=self.mongoHost, mongoPort=self.mongoPort, mongoDb=self.mongoDb)
node.setWalletEndpointArgs(self.walletEndpointArgs)
if Utils.Debug: Utils.Print("Node: %s", str(node))
node.checkPulse()
self.nodes=[node]
if defproduceraPrvtKey is not None:
self.defproduceraAccount.ownerPrivateKey=defproduceraPrvtKey
self.defproduceraAccount.activePrivateKey=defproduceraPrvtKey
if defproducerbPrvtKey is not None:
self.defproducerbAccount.ownerPrivateKey=defproducerbPrvtKey
self.defproducerbAccount.activePrivateKey=defproducerbPrvtKey
return True
示例3: discoverLocalNodes
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import setWalletEndpointArgs [as 别名]
def discoverLocalNodes(self, totalNodes, timeout=0):
nodes=[]
pgrepOpts="-fl"
# pylint: disable=deprecated-method
if platform.linux_distribution()[0] in ["Ubuntu", "LinuxMint", "Fedora","CentOS Linux","arch"]:
pgrepOpts="-a"
cmd="pgrep %s %s" % (pgrepOpts, Utils.EosServerName)
def myFunc():
psOut=None
try:
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
psOut=Utils.checkOutput(cmd.split())
return psOut
except subprocess.CalledProcessError as _:
pass
return None
psOut=Utils.waitForObj(myFunc, timeout)
if psOut is None:
Utils.Print("ERROR: No nodes discovered.")
return nodes
if Utils.Debug: Utils.Print("pgrep output: \"%s\"" % psOut)
for i in range(0, totalNodes):
pattern=r"[\n]?(\d+) (.* --data-dir var/lib/node_%02d .*)\n" % (i)
m=re.search(pattern, psOut, re.MULTILINE)
if m is None:
Utils.Print("ERROR: Failed to find %s pid. Pattern %s" % (Utils.EosServerName, pattern))
break
instance=Node(self.host, self.port + i, pid=int(m.group(1)), cmd=m.group(2), enableMongo=self.enableMongo, mongoHost=self.mongoHost, mongoPort=self.mongoPort, mongoDb=self.mongoDb)
instance.setWalletEndpointArgs(self.walletEndpointArgs)
if Utils.Debug: Utils.Print("Node>", instance)
nodes.append(instance)
return nodes
示例4: launch
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import setWalletEndpointArgs [as 别名]
def launch(self, pnodes=1, totalNodes=1, prodCount=1, topo="mesh", p2pPlugin="net", delay=1, onlyBios=False, dontKill=False
, dontBootstrap=False, totalProducers=None):
"""Launch cluster.
pnodes: producer nodes count
totalNodes: producer + non-producer nodes count
prodCount: producers per prodcuer node count
topo: cluster topology (as defined by launcher)
delay: delay between individual nodes launch (as defined by launcher)
delay 0 exposes a bootstrap bug where producer handover may have a large gap confusing nodes and bringing system to a halt.
"""
if not self.localCluster:
Utils.Print("WARNING: Cluster not local, not launching %s." % (Utils.EosServerName))
return True
if len(self.nodes) > 0:
raise RuntimeError("Cluster already running.")
producerFlag=""
if totalProducers:
assert(isinstance(totalProducers, (str,int)))
producerFlag="--producers %s" % (totalProducers)
if not Cluster.arePortsAvailable(set(range(self.port, self.port+totalNodes+1))):
Utils.Print("ERROR: Another process is listening on nodeos default port.")
return False
cmd="%s -p %s -n %s -s %s -d %s -i %s -f --p2p-plugin %s %s" % (
Utils.EosLauncherPath, pnodes, totalNodes, topo, delay, datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3],
p2pPlugin, producerFlag)
cmdArr=cmd.split()
if self.staging:
cmdArr.append("--nogen")
nodeosArgs="--max-transaction-time 5000 --abi-serializer-max-time-ms 5000 --filter-on * --p2p-max-nodes-per-host %d" % (totalNodes)
if not self.walletd:
nodeosArgs += " --plugin eosio::wallet_api_plugin"
if self.enableMongo:
nodeosArgs += " --plugin eosio::mongo_db_plugin --mongodb-wipe --delete-all-blocks --mongodb-uri %s" % self.mongoUri
if Utils.Debug:
nodeosArgs += " --contracts-console"
if nodeosArgs:
cmdArr.append("--nodeos")
cmdArr.append(nodeosArgs)
s=" ".join(cmdArr)
if Utils.Debug: Utils.Print("cmd: %s" % (s))
if 0 != subprocess.call(cmdArr):
Utils.Print("ERROR: Launcher failed to launch.")
return False
self.nodes=list(range(totalNodes)) # placeholder for cleanup purposes only
nodes=self.discoverLocalNodes(totalNodes, timeout=Utils.systemWaitTimeout)
if nodes is None or totalNodes != len(nodes):
Utils.Print("ERROR: Unable to validate %s instances, expected: %d, actual: %d" %
(Utils.EosServerName, totalNodes, len(nodes)))
return False
self.nodes=nodes
if onlyBios:
biosNode=Node(Cluster.__BiosHost, Cluster.__BiosPort)
biosNode.setWalletEndpointArgs(self.walletEndpointArgs)
if not biosNode.checkPulse():
Utils.Print("ERROR: Bios node doesn't appear to be running...")
return False
self.nodes=[biosNode]
# ensure cluster node are inter-connected by ensuring everyone has block 1
Utils.Print("Cluster viability smoke test. Validate every cluster node has block 1. ")
if not self.waitOnClusterBlockNumSync(1):
Utils.Print("ERROR: Cluster doesn't seem to be in sync. Some nodes missing block 1")
return False
if dontBootstrap:
Utils.Print("Skipping bootstrap.")
return True
Utils.Print("Bootstrap cluster.")
if not Cluster.bootstrap(totalNodes, prodCount, Cluster.__BiosHost, Cluster.__BiosPort, dontKill, onlyBios):
Utils.Print("ERROR: Bootstrap failed.")
return False
# validate iniX accounts can be retrieved
producerKeys=Cluster.parseClusterKeys(totalNodes)
if producerKeys is None:
Utils.Print("ERROR: Unable to parse cluster info")
return False
def initAccountKeys(account, keys):
account.ownerPrivateKey=keys["private"]
account.ownerPublicKey=keys["public"]
account.activePrivateKey=keys["private"]
account.activePublicKey=keys["public"]
for name,_ in producerKeys.items():
account=Account(name)
#.........这里部分代码省略.........
示例5: bootstrap
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import setWalletEndpointArgs [as 别名]
def bootstrap(totalNodes, prodCount, biosHost, biosPort, dontKill=False, onlyBios=False):
"""Create 'prodCount' init accounts and deposits 10000000000 SYS in each. If prodCount is -1 will initialize all possible producers.
Ensure nodes are inter-connected prior to this call. One way to validate this will be to check if every node has block 1."""
Utils.Print("Starting cluster bootstrap.")
biosNode=Node(biosHost, biosPort)
if not biosNode.checkPulse():
Utils.Print("ERROR: Bios node doesn't appear to be running...")
return False
producerKeys=Cluster.parseClusterKeys(totalNodes)
# should have totalNodes node plus bios node
if producerKeys is None or len(producerKeys) < (totalNodes+1):
Utils.Print("ERROR: Failed to parse private keys from cluster config files.")
return False
walletMgr=WalletMgr(True)
walletMgr.killall()
walletMgr.cleanup()
if not walletMgr.launch():
Utils.Print("ERROR: Failed to launch bootstrap wallet.")
return False
biosNode.setWalletEndpointArgs(walletMgr.walletEndpointArgs)
try:
ignWallet=walletMgr.create("ignition")
if ignWallet is None:
Utils.Print("ERROR: Failed to create ignition wallet.")
return False
eosioName="eosio"
eosioKeys=producerKeys[eosioName]
eosioAccount=Account(eosioName)
eosioAccount.ownerPrivateKey=eosioKeys["private"]
eosioAccount.ownerPublicKey=eosioKeys["public"]
eosioAccount.activePrivateKey=eosioKeys["private"]
eosioAccount.activePublicKey=eosioKeys["public"]
if not walletMgr.importKey(eosioAccount, ignWallet):
Utils.Print("ERROR: Failed to import %s account keys into ignition wallet." % (eosioName))
return False
contract="eosio.bios"
contractDir="contracts/%s" % (contract)
wastFile="contracts/%s/%s.wast" % (contract, contract)
abiFile="contracts/%s/%s.abi" % (contract, contract)
Utils.Print("Publish %s contract" % (contract))
trans=biosNode.publishContract(eosioAccount.name, contractDir, wastFile, abiFile, waitForTransBlock=True)
if trans is None:
Utils.Print("ERROR: Failed to publish contract %s." % (contract))
return False
Node.validateTransaction(trans)
Utils.Print("Creating accounts: %s " % ", ".join(producerKeys.keys()))
producerKeys.pop(eosioName)
accounts=[]
for name, keys in producerKeys.items():
initx = None
initx = Account(name)
initx.ownerPrivateKey=keys["private"]
initx.ownerPublicKey=keys["public"]
initx.activePrivateKey=keys["private"]
initx.activePublicKey=keys["public"]
trans=biosNode.createAccount(initx, eosioAccount, 0)
if trans is None:
Utils.Print("ERROR: Failed to create account %s" % (name))
return False
Node.validateTransaction(trans)
accounts.append(initx)
transId=Node.getTransId(trans)
if not biosNode.waitForTransInBlock(transId):
Utils.Print("ERROR: Failed to validate transaction %s got rolled into a block on server port %d." % (transId, biosNode.port))
return False
Utils.Print("Validating system accounts within bootstrap")
biosNode.validateAccounts(accounts)
if not onlyBios:
if prodCount == -1:
setProdsFile="setprods.json"
if Utils.Debug: Utils.Print("Reading in setprods file %s." % (setProdsFile))
with open(setProdsFile, "r") as f:
setProdsStr=f.read()
Utils.Print("Setting producers.")
opts="--permission [email protected]"
myTrans=biosNode.pushMessage("eosio", "setprods", setProdsStr, opts)
if myTrans is None or not myTrans[0]:
Utils.Print("ERROR: Failed to set producers.")
return False
else:
counts=dict.fromkeys(range(totalNodes), 0) #initialize node prods count to 0
setProdsStr='{"schedule": ['
firstTime=True
prodNames=[]
for name, keys in producerKeys.items():
if counts[keys["node"]] >= prodCount:
#.........这里部分代码省略.........