This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
go-monero/pkg/rpc/daemon/daemon_example_test.go
2022-10-05 09:40:23 +02:00

33 lines
693 B
Go

package daemon_test
import (
"context"
"fmt"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc"
"git.gammaspectra.live/P2Pool/go-monero/pkg/rpc/daemon"
)
// nolint
func ExampleGetHeight() {
ctx := context.Background()
addr := "http://localhost:18081"
// instantiate a generic RPC client
//
client, err := rpc.NewClient(addr)
if err != nil {
panic(fmt.Errorf("new client for '%s': %w", addr, err))
}
// instantiate a daemon-specific client and call the `get_height`
// remote procedure.
//
height, err := daemon.NewClient(client).GetHeight(ctx)
if err != nil {
panic(fmt.Errorf("get height: %w", err))
}
fmt.Printf("height=%d hash=%s\n", height.Height, height.Hash)
}