Skip to content

Commit

Permalink
Optimize DAG traversal in insertFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbuchwald committed Jun 16, 2020
1 parent 58c9093 commit 0fdddae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions snow/engine/avalanche/transitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ func (t *Transitive) reinsertFrom(vdr ids.ShortID, vtxID ids.ID) (bool, error) {

func (t *Transitive) insertFrom(vdr ids.ShortID, vtx avalanche.Vertex) (bool, error) {
issued := true
vts := []avalanche.Vertex{vtx}
for len(vts) > 0 {
vtx := vts[0]
vts = vts[1:]
vertexHeap := newMaxVertexHeap()
vertexHeap.Push(vtx)
for vertexHeap.Len() > 0 {
vtx := vertexHeap.Pop()

if t.Consensus.VertexIssued(vtx) {
continue
Expand All @@ -353,7 +353,7 @@ func (t *Transitive) insertFrom(vdr ids.ShortID, vtx avalanche.Vertex) (bool, er
t.sendRequest(vdr, parent.ID())
issued = false
} else {
vts = append(vts, parent)
vertexHeap.Push(parent)
}
}

Expand Down

0 comments on commit 0fdddae

Please sign in to comment.