Skip to content

Commit

Permalink
fixed a small bug in the Report function
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikspatil024 committed Sep 26, 2022
1 parent 40f0ff1 commit f97de3a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion core/blockstm/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ func BuildDAG(deps TxnInputOutput) (d DAG) {
return
}

func bubbleSort(n []int, m []string) ([]int, []string) {
var isDone = false

for !isDone {
isDone = true

var i = 0
for i < len(n)-1 {
if n[i] > n[i+1] {
n[i], n[i+1] = n[i+1], n[i]
m[i], m[i+1] = m[i+1], m[i]
isDone = false
}
i++
}
}

return n, m
}

func (d DAG) Report(out func(string)) {
roots := make([]int, 0)
rootIds := make([]string, 0)
Expand All @@ -80,7 +100,7 @@ func (d DAG) Report(out func(string)) {
rootIds = append(rootIds, k)
}

sort.Ints(roots)
roots, rootIds = bubbleSort(roots, rootIds)
fmt.Println(roots)

makeStrs := func(ints []int) (ret []string) {
Expand Down

0 comments on commit f97de3a

Please sign in to comment.