View block synchronization information

This section describes how to view synchronization information between the currently used chain node and the master node.

The reference code is as follows:

package main

import (
	"context"
	"fmt"

	cess "github.com/CESSProject/cess-go-sdk"
)

var RPC_ADDRS = []string{
	"wss://testnet-rpc0.cess.cloud/ws/",
	"wss://testnet-rpc1.cess.cloud/ws/",
	"wss://testnet-rpc2.cess.cloud/ws/",
}

func main() {
	sdk, err := cess.New(
		context.Background(),
		cess.ConnectRpcAddrs(RPC_ADDRS),
	)
	if err != nil {
		panic(err)
	}

	// Query block synchronization information
	fmt.Println(sdk.SyncState())
}

When CurrentBlock is equal to HighestBlock, synchronization is completed.

Last updated