git.gammaspectra.live/P2Pool/consensus/v3@v3.8.0/monero/client/rpc/daemon/daemon_example_test.go (about) 1 package daemon_test 2 3 import ( 4 "context" 5 "fmt" 6 7 "git.gammaspectra.live/P2Pool/consensus/v3/monero/client/rpc" 8 "git.gammaspectra.live/P2Pool/consensus/v3/monero/client/rpc/daemon" 9 ) 10 11 // nolint 12 func ExampleGetHeight() { 13 ctx := context.Background() 14 addr := "http://localhost:18081" 15 16 // instantiate a generic RPC client 17 // 18 client, err := rpc.NewClient(addr) 19 if err != nil { 20 panic(fmt.Errorf("new client for '%s': %w", addr, err)) 21 } 22 23 // instantiate a daemon-specific client and call the `get_height` 24 // remote procedure. 25 // 26 height, err := daemon.NewClient(client).GetHeight(ctx) 27 if err != nil { 28 panic(fmt.Errorf("get height: %w", err)) 29 } 30 31 fmt.Printf("height=%d hash=%s\n", height.Height, height.Hash) 32 }