コード例 #1
0
		if pid == localConfig['id']:
			safe_print('You cannot take down a network communication between yourself')
		else:
			connectGraph.network_up(pid)
	elif cmd == 'printBlockchain':
		blockchain = transactionManager.getBlockchain()
		blockchainStr = []
		for i in range(0, len(blockchain)):
			block = blockchain[i]
			blockStr = []
			for transaction in block:
				blockStr.append(transactionManager.getTransactionStr(transaction))
			blockchainStr.append("Block {0}: {1}".format(i, '; '.join(blockStr)))
		safe_print('\n'.join(blockchainStr))
	elif cmd == 'printBalance':
		safe_print(transactionManager.getBalance())
	elif cmd == 'printQueue':
		block = transactionManager.getQueue()
		blockStr = []
		for transaction in block:
			blockStr.append(transactionManager.getTransactionStr(transaction))
		if len(blockStr) == 0:
			blockStrRepr = "None"
		else:
			blockStrRepr = '; '.join(blockStr)
		safe_print("Queued Transactions: {0}".format(blockStrRepr))
	elif cmd == 'attemptSave':
		paxosManager.attempt_save()
	elif cmd == 'serverCrash':
		paxosManager.lock.acquire() # take the paxosManager lock and don't release it
		paxosManager.dumpDisk()