simplify send code and loop

Treat send in block proposer as in validators to simplify
code and fix steps. Previously first step included first two
timelots: initial send by block proposer and first send by
validators.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-01-26 01:12:13 +01:00
parent 6c6e10b81f
commit 50a210ad99
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
2 changed files with 17 additions and 22 deletions

View File

@ -99,19 +99,20 @@ class Simulator:
missingSamples = expected - arrived
missingVector = []
steps = 0
while(missingSamples > 0):
while(True):
missingVector.append(missingSamples)
oldMissingSamples = missingSamples
for i in range(0,self.shape.numberValidators):
self.validators[i].sendRows()
self.validators[i].sendColumns()
for i in range(1,self.shape.numberValidators):
self.validators[i].receiveRowsColumns()
for i in range(1,self.shape.numberValidators):
self.validators[i].restoreRows()
self.validators[i].restoreColumns()
self.validators[i].sendRows()
self.validators[i].sendColumns()
for i in range(0,self.shape.numberValidators):
self.validators[i].logRows()
self.validators[i].logColumns()
for i in range(0,self.numberValidators):
self.validators[i].updateStats()
arrived, expected = self.glob.checkStatus(self.validators)

View File

@ -89,14 +89,14 @@ class Validator:
self.block.data[i] = 1
else:
self.block.data[i] = 0
self.changedRow = {id:True for id in self.rowIDs}
self.changedColumn = {id:True for id in self.columnIDs}
nbFailures = self.block.data.count(0)
measuredFailureRate = nbFailures * 100 / (self.shape.blockSize * self.shape.blockSize)
self.logger.debug("Number of failures: %d (%0.02f %%)", nbFailures, measuredFailureRate, extra=self.format)
#broadcasted.print()
for id in range(self.shape.blockSize):
self.sendColumn(id)
for id in range(self.shape.blockSize):
self.sendRow(id)
def getColumn(self, index):
return self.block.getColumn(index)
@ -177,22 +177,16 @@ class Validator:
self.statsTxInSlot += toSend.count(1)
def sendRows(self):
if self.amIproposer == 1:
self.logger.error("I am a block proposer", extra=self.format)
else:
self.logger.debug("Sending restored rows...", extra=self.format)
for r in self.rowIDs:
if self.changedRow[r]:
self.sendRow(r)
self.logger.debug("Sending restored rows...", extra=self.format)
for r in self.rowIDs:
if self.changedRow[r]:
self.sendRow(r)
def sendColumns(self):
if self.amIproposer == 1:
self.logger.error("I am a block proposer", extra=self.format)
else:
self.logger.debug("Sending restored columns...", extra=self.format)
for c in self.columnIDs:
if self.changedColumn[c]:
self.sendColumn(c)
self.logger.debug("Sending restored columns...", extra=self.format)
for c in self.columnIDs:
if self.changedColumn[c]:
self.sendColumn(c)
def logRows(self):
if self.logger.isEnabledFor(logging.DEBUG):