simpliy sendRow and sendColumn calls

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2022-12-20 12:45:35 +01:00
parent 7d79879f66
commit faa2954893
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
1 changed files with 8 additions and 8 deletions

View File

@ -74,9 +74,9 @@ class Validator:
self.block.data[i] = 0 self.block.data[i] = 0
#broadcasted.print() #broadcasted.print()
for id in range(self.blockSize): for id in range(self.blockSize):
self.sendColumn(id, id) self.sendColumn(id)
for id in range(self.blockSize): for id in range(self.blockSize):
self.sendRow(id, id) self.sendRow(id)
def getColumn(self, index): def getColumn(self, index):
return self.block.getColumn(index) return self.block.getColumn(index)
@ -106,14 +106,14 @@ class Validator:
self.block.merge(self.receivedBlock) self.block.merge(self.receivedBlock)
def sendColumn(self, c, columnID): def sendColumn(self, columnID):
line = self.getColumn(columnID) line = self.getColumn(columnID)
if line.any(): if line.any():
self.logger.debug("col %d -> %s", columnID, self.columnNeighbors[columnID] , extra=self.format) self.logger.debug("col %d -> %s", columnID, self.columnNeighbors[columnID] , extra=self.format)
for n in self.columnNeighbors[columnID]: for n in self.columnNeighbors[columnID]:
n.receiveColumn(columnID, line) n.receiveColumn(columnID, line)
def sendRow(self, r, rowID): def sendRow(self, rowID):
line = self.getRow(rowID) line = self.getRow(rowID)
if line.any(): if line.any():
self.logger.debug("row %d -> %s", rowID, self.rowNeighbors[rowID], extra=self.format) self.logger.debug("row %d -> %s", rowID, self.rowNeighbors[rowID], extra=self.format)
@ -125,16 +125,16 @@ class Validator:
self.logger.error("I am a block proposer", extra=self.format) self.logger.error("I am a block proposer", extra=self.format)
else: else:
self.logger.debug("Sending restored rows...", extra=self.format) self.logger.debug("Sending restored rows...", extra=self.format)
for r in range(len(self.rowIDs)): for r in self.rowIDs:
self.sendRow(r, self.rowIDs[r]) self.sendRow(r)
def sendColumns(self): def sendColumns(self):
if self.proposer == 1: if self.proposer == 1:
self.logger.error("I am a block proposer", extra=self.format) self.logger.error("I am a block proposer", extra=self.format)
else: else:
self.logger.debug("Sending restored columns...", extra=self.format) self.logger.debug("Sending restored columns...", extra=self.format)
for c in range(len(self.columnIDs)): for c in self.columnIDs:
self.sendColumn(c, self.columnIDs[c]) self.sendColumn(c)
def logRows(self): def logRows(self):
if self.logger.isEnabledFor(logging.DEBUG): if self.logger.isEnabledFor(logging.DEBUG):