def __init__(self,id,x,y):
        self.id = id
        self.x = x
        self.y = y
        self.m_count = 1
        self.recv_buf = []
        self.send_buf = []
        self.sent_message = []
        self.receipt_message = []
        self.stat_receive_from = []
        self.stat_received = 0
        self.stat_just_received = False
        self.ledgerNames = ''

        self.config_receive_range = 300 * 300

        self.node_core = node_core_M.node_core(id)
Example #2
0
import node_core_M

nodeID = 'aaaaaaaa'
requestID_index = 10

node_core = node_core_M.node_core(nodeID)
node_core.create_new_ledger()
node_core.create_new_ledger()

node_core.set_initial_account(0, 'A0000001', 1000)
node_core.set_initial_account(1, 'B0000002', 600)
node_core.set_initial_account(0, 'C0000003', 3000)

#窓口ノードがスマホ等から新しいコマンドメッセージを受信
#receive a new request from end-terminal
ReceivedPackets = []
newTransactionRequest = {
    'type':
    'newRequest',
    'payload': [{
        'type': 'pointTransfer',
        'from': 'B0000002',
        'to': 'C0000003',
        'amount': 500
    }]
}
ReceivedPackets.append(newTransactionRequest)
print("\nNode [%s]  Received a new reuest from an end terminal:   %s\n" %
      (nodeID, ReceivedPackets))

transmit_packets = node_core.distribute_new_requests(ReceivedPackets)
Example #3
0
import random
import node_core_M
import copy

nodes = []

ComErrorRatio = 20  # %
dataErrorRatio = 5  # %

#初期ノード作成 テスト用

i = 0
nodeID = ("node%04d" % i)
node = node_core_M.node_core(nodeID)
node.create_new_ledger()
node.create_new_ledger()
node.set_initial_account(0, 'A0000001', 1000)
node.set_initial_account(1, 'B0000002', 2000)
node.set_initial_account(0, 'C0000003', 3000)
ledgerlist = node.get_ledger_ID_list()
ledger1 = node.get_ledger_contents(ledgerlist[0])
ledger2 = node.get_ledger_contents(ledgerlist[1])
nodes.append(node)

print(ledger1)
print(ledger2)

#ノードをN個作成 node0の台帳野中身を乱数で配置

for i in range(1, 5):
    nodeID = ("node%04d" % i)