go-stakenet
A collection of different clients for Stakenet (XSN) techologies. Find out more about Stakenet: https://stakenet.io/
You can see all the clients active and in use on https://stakenet.info
Installation
requirement: go v1.11+
> go get -u github.com/cwntr/go-stakenet
Stakenet (XSN) Clients implemented
Usage Explorer Client
import (
"fmt"
"github.com/cwntr/go-stakenet/explorer"
"github.com/cwntr/go-stakenet/tools"
)
func testExplorer() {
// no parameter will do on-fly-requests and responses without caching
e := explorer.NewXSNExplorerAPIClient(nil)
stats, err := e.GetStats()
if err != nil {
return
}
fmt.Printf("stats: %v\n", stats)
// with recorder pointer parameter will locally store request and response pairs. This should only be used for responses
// that will not change. e.g. get all details of a block, since a block is not gonna change.
recorderPath := "records/xsn_block/%s"
blockHash := "bf069bd8e1ce427c3dd7adf1aacc907051536210351bb8abcc76325486bce61d"
blockRec, err := tools.CreateRecorder(fmt.Sprintf(recorderPath, blockHash))
if err != nil {
return
}
e2 := explorer.NewXSNExplorerAPIClient(blockRec)
blockData, err := e2.GetBlockByQuery(blockHash)
blockRec.Stop() //flush
fmt.Printf("blockData: %v\n", blockData)
}