Skip to content

Commit

Permalink
feat: trace transaction command
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed May 5, 2023
1 parent 95fc037 commit a6f1f7c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fmt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"fmt"
"strings"

"github.com/chainbound/cbctl/api"
)

func printTransactionTrace(trace []*api.TraceEntry, showSource bool) {
if showSource {
fmt.Printf("Timestamp\tNode ID\t\t\tRegion\t\t\tObservation Type\tSource\n")
} else {
fmt.Printf("Timestamp\tNode ID\t\t\tRegion\t\t\tObservation Type\n")

}
for _, entry := range trace {
chunks := strings.Split(entry.NodeID, "-")[:3]
id := strings.Join(chunks, "-")
if showSource {
fmt.Printf("[%d]\t%s\t(%s)\t\t%s\t\t\t%s\n", entry.Timestamp/1000, id, entry.Region, entry.ObservationType, entry.Source)
} else {
fmt.Printf("[%d]\t%s\t(%s)\t\t%s\n", entry.Timestamp/1000, id, entry.Region, entry.ObservationType)
}
}
}

0 comments on commit a6f1f7c

Please sign in to comment.