4

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 1

5

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)
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.