Block Monitor

A Tezos node can notify applications when new blocks are attached to the chain. The Tezos RPC calls this monitor and technically it's a long-poll implementation. Here's how to use this feature in TzGo:
import ""
// init SDK client
c, _ := rpc.NewClient("", nil)
// create block header monitor
mon := rpc.NewBlockHeaderMonitor()
defer mon.Close()
// all SDK functions take a context, here we just use a dummy
ctx := context.TODO()
// register the block monitor with our client
if err := c.MonitorBlockHeader(ctx, mon); err != nil {
// wait for new block headers
for {
head, err := mon.Recv(ctx)
if err != nil {
// do smth with the block header
fmt.Printf("New block %s\n", head.Hash)