add dumbRandomScheduler parameter
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
b7dab5bad9
commit
0c91eff67b
|
@ -123,6 +123,7 @@ class Validator:
|
|||
|
||||
self.perNeighborQueue = False # queue incoming messages to outgoing connections on arrival (as typical GossipSub impl)
|
||||
self.perNodeQueue = False # keep a global queue of incoming messages for later sequential dispatch
|
||||
self.dumbRandomScheduler = False # dumb random scheduler
|
||||
self.sched = self.nextToSend()
|
||||
|
||||
def logIDs(self):
|
||||
|
@ -374,34 +375,37 @@ class Validator:
|
|||
if self.statsTxInSlot >= self.bwUplink:
|
||||
return
|
||||
|
||||
tries = 100
|
||||
while tries:
|
||||
if self.rowIDs:
|
||||
rID = random.choice(self.rowIDs)
|
||||
cID = random.randrange(0, self.shape.blockSize)
|
||||
if self.block.getSegment(rID, cID) :
|
||||
neigh = random.choice(list(self.rowNeighbors[rID].values()))
|
||||
if not neigh.sent[cID] and not neigh.receiving[cID] :
|
||||
neigh.sent[cID] = 1
|
||||
neigh.node.receiveSegment(rID, cID, self.ID)
|
||||
self.statsTxInSlot += 1
|
||||
tries = 100
|
||||
if self.statsTxInSlot >= self.bwUplink:
|
||||
return
|
||||
if self.columnIDs:
|
||||
cID = random.choice(self.columnIDs)
|
||||
rID = random.randrange(0, self.shape.blockSize)
|
||||
if self.block.getSegment(rID, cID) :
|
||||
neigh = random.choice(list(self.columnNeighbors[cID].values()))
|
||||
if not neigh.sent[rID] and not neigh.receiving[rID] :
|
||||
neigh.sent[rID] = 1
|
||||
neigh.node.receiveSegment(rID, cID, self.ID)
|
||||
self.statsTxInSlot += 1
|
||||
tries = 100
|
||||
tries -= 1
|
||||
if self.statsTxInSlot >= self.bwUplink:
|
||||
return
|
||||
return
|
||||
if self.dumbRandomScheduler:
|
||||
# dumb random scheduler picking segments at random and trying to send it
|
||||
tries = 100
|
||||
t = tries
|
||||
while t:
|
||||
if self.rowIDs:
|
||||
rID = random.choice(self.rowIDs)
|
||||
cID = random.randrange(0, self.shape.blockSize)
|
||||
if self.block.getSegment(rID, cID) :
|
||||
neigh = random.choice(list(self.rowNeighbors[rID].values()))
|
||||
if not neigh.sent[cID] and not neigh.receiving[cID] :
|
||||
neigh.sent[cID] = 1
|
||||
neigh.node.receiveSegment(rID, cID, self.ID)
|
||||
self.statsTxInSlot += 1
|
||||
t = tries
|
||||
if self.statsTxInSlot >= self.bwUplink:
|
||||
return
|
||||
if self.columnIDs:
|
||||
cID = random.choice(self.columnIDs)
|
||||
rID = random.randrange(0, self.shape.blockSize)
|
||||
if self.block.getSegment(rID, cID) :
|
||||
neigh = random.choice(list(self.columnNeighbors[cID].values()))
|
||||
if not neigh.sent[rID] and not neigh.receiving[rID] :
|
||||
neigh.sent[rID] = 1
|
||||
neigh.node.receiveSegment(rID, cID, self.ID)
|
||||
self.statsTxInSlot += 1
|
||||
t = tries
|
||||
t -= 1
|
||||
if self.statsTxInSlot >= self.bwUplink:
|
||||
return
|
||||
return
|
||||
|
||||
for n in self.sched:
|
||||
neigh = n.neigh
|
||||
|
|
Loading…
Reference in New Issue