Skip to content

Commit

Permalink
optimized e1, e2, r2
Browse files Browse the repository at this point in the history
  • Loading branch information
lunfardo314 committed Feb 13, 2025
1 parent 4255439 commit b563ade
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion sequencer/task/proposer_endorse1.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func endorse1ProposeGenerator(p *Proposer) (*attacher.IncrementalAttacher, bool)
p.Task.slotData.lastTimeBacklogCheckedE1 = time.Now()
a := p.ChooseFirstExtendEndorsePair(false, func(extend vertex.WrappedOutput, endorse *vertex.WrappedTx) bool {
if newOutputsArrived {
// use pair with new outputs
// use pair with new tag-along outputs
return true
}
return p.Task.slotData.checkCombination(extend, endorse)
Expand Down
23 changes: 14 additions & 9 deletions sequencer/task/slot_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,28 @@ func extendEndorseCombinationHash(extend vertex.WrappedOutput, endorse ...*verte

var buf bytes.Buffer

buf.Write(extend.VID.ID[:])
buf.WriteByte(extend.Index)
for i := range endorseSorted {
buf.Write(endorseSorted[i].ID[:])
}
buf.Write(extend.VID.ID[:])
buf.WriteByte(extend.Index)
buf.WriteByte(byte(len(endorse))) // need this to distinguish between target extend-endorse combinations

retSlice := blake2b.Sum256(buf.Bytes())
copy(ret[:], retSlice[:])
return
}

// checkCombination checks combination and inserts into the list. Returns true if it is new combination
func (s *SlotData) checkCombination(extend vertex.WrappedOutput, endorse ...*vertex.WrappedTx) (ret bool) {
func (s *SlotData) checkCombination(extend vertex.WrappedOutput, endorse ...*vertex.WrappedTx) bool {
combHash := extendEndorseCombinationHash(extend, endorse...)
s.withWriteLock(func() {
if ret = !s.alreadyCheckedExtendEndorseCombination.Contains(combHash); ret {
s.alreadyCheckedExtendEndorseCombination.Insert(combHash)
}
})
return

s.mutex.Lock()
defer s.mutex.Unlock()

if s.alreadyCheckedExtendEndorseCombination.Contains(combHash) {
return false
}
s.alreadyCheckedExtendEndorseCombination.Insert(combHash)
return true
}

0 comments on commit b563ade

Please sign in to comment.