How I can get notify (like newblockinfo in bitcoin or getlastblock in ethereum or bitcoin) on new ledger in blockchain with go-sdk
1 Answer
Just use Client.StreamLedgers
method:
client := DefaultPublicNetClient
cursor := Cursor("now")
// Call `cancel()` to stop streaming
ctx, cancel := context.WithCancel(context.Background())
err := client.StreamLedgers(ctx, &cursor, func(l Ledger) {
fmt.Println(l.Sequence)
})
if err != nil {
fmt.Println(err)
}