66 "fmt"
77 "io"
88 "os"
9+ "time"
910
1011 "github.com/spf13/cobra"
1112 "github.com/streamingfast/cli/sflags"
@@ -29,14 +30,15 @@ The endpoint can be specified in the following formats:
2930 - https://host[:port] (automatically uses SSL connection, defaults to port 443)
3031
3132When using http:// or https:// prefixes, the --plaintext flag is automatically determined from the URL scheme.` ,
32- Args : cobra .ExactArgs (2 ),
33- RunE : getFirehoseClientE (chain , logger ),
33+ Args : cobra .ExactArgs (2 ),
34+ RunE : getFirehoseClientE (chain , logger ),
3435 }
3536
3637 addFirehoseStreamClientFlagsToSet (cmd .Flags (), chain )
3738
3839 cmd .Flags ().Bool ("final-blocks-only" , false , "Only ask for final blocks" )
3940 cmd .Flags ().Bool ("print-cursor-only" , false , "Skip block decoding, only print the step cursor (useful for performance testing)" )
41+ cmd .Flags ().Bool ("print-clock-only" , false , "Skip block decoding, only print the block timestamp and latency" )
4042
4143 return cmd
4244}
@@ -61,6 +63,7 @@ func getFirehoseClientE[B firecore.Block](chain *firecore.Chain[B], rootLog *zap
6163 }
6264
6365 printCursorOnly := sflags .MustGetBool (cmd , "print-cursor-only" )
66+ printClockOnly := sflags .MustGetBool (cmd , "print-clock-only" )
6467
6568 request := & pbfirehose.Request {
6669 StartBlockNum : blockRange .Start ,
@@ -88,7 +91,7 @@ func getFirehoseClientE[B firecore.Block](chain *firecore.Chain[B], rootLog *zap
8891 resps := make (chan * respChan , 10 )
8992 allDone := make (chan bool )
9093
91- if ! printCursorOnly {
94+ if ! printCursorOnly && ! printClockOnly {
9295 // print the responses linearly
9396 go func () {
9497 for resp := range resps {
@@ -120,6 +123,10 @@ func getFirehoseClientE[B firecore.Block](chain *firecore.Chain[B], rootLog *zap
120123 fmt .Printf ("%s - %s\n " , response .Step .String (), response .Cursor )
121124 continue
122125 }
126+ if printClockOnly {
127+ fmt .Printf ("%d -- %s %s latency(ms): %5d\n " , response .Metadata .Num , response .Metadata .Time .AsTime ().UTC ().Format ("15:04:05" ), time .Now ().UTC ().Format ("15:04:05.000" ), time .Since (response .Metadata .Time .AsTime ()).Milliseconds ())
128+ continue
129+ }
123130
124131 resp := & respChan {
125132 ch : make (chan string ),
0 commit comments