Skip to content

Commit

Permalink
Merge pull request #251 from aaronbuchwald/optimize-insert-from
Browse files Browse the repository at this point in the history
Optimize DAG traversal in insertFrom
  • Loading branch information
StephenButtolph authored Jun 16, 2020
2 parents 58c9093 + 0fdddae commit b1923d7
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 b1923d7

Please sign in to comment.