diff --git a/block.py b/block.py index 576cc2c..36b900e 100644 --- a/block.py +++ b/block.py @@ -12,3 +12,4 @@ def __init__(self, identifier, transactionList, params): self.identifier = identifier self.transactionList = transactionList self.hash = self.identifier+"_"+getHash(10) + self.size = params['blockSize'] diff --git a/fullNode.py b/fullNode.py index 57dd248..0a82245 100644 --- a/fullNode.py +++ b/fullNode.py @@ -38,6 +38,7 @@ def receiveBlock(self): """Receive newly mined block from neighbour""" while True: b = yield self.pipes[self.identifier].get() + yield self.env.timeout(b.size * 10) if len(self.blockchain) > 0: currID = int(self.blockchain[-1].identifier[1:]) else: diff --git a/miner.py b/miner.py index 9734119..892768e 100644 --- a/miner.py +++ b/miner.py @@ -70,6 +70,7 @@ def receiveBlock(self): """Receive newly mined block from neighbour""" while True: b = yield self.pipes[self.identifier].get() + yield self.env.timeout(b.size * 10) if len(self.blockchain) > 0: currID = int(self.blockchain[-1].identifier[1:]) else: diff --git a/pipe.py b/pipe.py index fd5bf35..2607f88 100644 --- a/pipe.py +++ b/pipe.py @@ -15,8 +15,11 @@ def latencyPut(self, value, delay): return self.store.put(value) def put(self, value, sourceLocation): + # Simulate transmission delay + # yield self.env.timeout(value.size * 1000) destLocation = self.allNodes[self.identifier].location delay = getTransmissionDelay(sourceLocation, destLocation) + delay = delay + value.size * 10 return self.env.process(self.latencyPut(value, delay)) def get(self):