Пример #1
0
 def receive_tx_list_event(txList, gatewayId, tokenTime, eventTime):
     eventType = "receive_tx_list"
     if eventTime <= p.simTime:
         block = AB()
         block.transactions = txList.copy()
         block.timestamp = tokenTime
         event = Event(eventType, gatewayId, eventTime, block)
         Queue.add_event(event)
Пример #2
0
 def create_block_event_AB(node, eventTime, receiverGatewayId):
     eventType = "create_block"
     if eventTime <= p.simTime:
         # Populate event attributes
         block = AB()
         block.id = random.randrange(100000000000)
         block.timestamp = eventTime
         block.nodeId = node.id
         block.gatewayIds = node.gatewayIds
         block.receiverGatewayId = receiverGatewayId
         event = Event(eventType, node.id, eventTime, block)
         Queue.add_event(event)  # add the event to the queue
Пример #3
0
    def create_block_event(miner, eventTime):
        eventType = "create_block"
        if eventTime <= p.simTime:
            # prepare attributes for the event
            block = Block()
            block.miner = miner.id
            block.depth = len(miner.blockchain)
            block.id = random.randrange(100000000000)
            block.previous = miner.last_block().id
            block.timestamp = eventTime

            event = Event(eventType, block.miner, eventTime,
                          block)  # create the event
            Queue.add_event(event)  # add the event to the queue
Пример #4
0
    def create_block_event(miner, eventTime):
        eventType = "create_block"
        if eventTime <= p.simTime:
            # prepare attributes for the event
            block = Block()
            block.miner = miner.id
            block.id = random.randrange(100000000000)
            block.timestamp = eventTime
            if p.model == 3:
                virtual_block = miner.next_unfinished_virtual_block()
                block.depth = virtual_block.depth
                block.branch_id = virtual_block.next_branch_id()
                miner.mining_branch = block
            else:
                block.depth = len(miner.blockchain)
                block.previous = miner.last_block().id

            event = Event(eventType, block.miner, eventTime,
                          block)  # create the event
            Queue.add_event(event)  # add the event to the queue
Пример #5
0
 def receive_block_event(recipient, block, event_time):
     if event_time <= p.simTime:
         e = Event("receive_block", recipient.id, event_time, block)
         Queue.add_event(e)
Пример #6
0
 def receive_block_event(recipient, block, blockDelay):
     receive_block_time = block.timestamp + blockDelay
     if receive_block_time <= p.simTime:
         e = Event("receive_block", recipient.id, receive_block_time, block)
         Queue.add_event(e)
Пример #7
0
 def create_attack_event(node_num, event_time):
     event_type = "attack_node"
     event = Event(event_type, node_num, event_time, None) 
     Queue.add_event(event)