rpc: adjust client documentation

This commit is contained in:
Anna Shaleva 2021-09-08 13:02:14 +03:00
parent 913e3878c5
commit df8141ff7d
4 changed files with 25 additions and 9 deletions

View file

@ -110,9 +110,10 @@ func New(ctx context.Context, endpoint string, opts Options) (*Client, error) {
return cl, nil return cl, nil
} }
// Init sets magic of the network client connected to and native NEO and GAS // Init sets magic of the network client connected to, stateRootInHeader option
// contracts scripthashes. This method should be called before any transaction-, // and native NEO, GAS and Policy contracts scripthashes. This method should be
// header- or block-related requests in order to deserialize responses properly. // called before any transaction-, header- or block-related requests in order to
// deserialize responses properly.
func (c *Client) Init() error { func (c *Client) Init() error {
version, err := c.GetVersion() version, err := c.GetVersion()
if err != nil { if err != nil {

View file

@ -12,38 +12,47 @@ return a more pretty printed response from the server instead of
a raw hex string. a raw hex string.
TODO: TODO:
Add missing methods to client.
Allow client to connect using client cert. Allow client to connect using client cert.
More in-depth examples. More in-depth examples.
Supported methods Supported methods
calculatenetworkfee
getapplicationlog getapplicationlog
getbestblockhash getbestblockhash
getblock getblock
getblockcount getblockcount
getblockhash getblockhash
getblockheader getblockheader
getblocksysfee getblockheadercount
getcommittee
getconnectioncount getconnectioncount
getcontractstate getcontractstate
getnativecontracts
getnep17balances getnep17balances
getnep17transfers getnep17transfers
getpeers getpeers
getrawmempool getrawmempool
getrawtransaction getrawtransaction
getstateheight
getstorage getstorage
gettransactionheight gettransactionheight
getunclaimedgas getunclaimedgas
getvalidators getnextblockvalidators
getversion getversion
invoke
invokefunction invokefunction
invokescript invokescript
invokecontractverify
sendrawtransaction sendrawtransaction
submitblock submitblock
submitoracleresponse
validateaddress validateaddress
Extensions:
getblocksysfee
submitnotaryrequest
Unsupported methods Unsupported methods
claimgas claimgas

View file

@ -19,6 +19,12 @@ func Example() {
os.Exit(1) os.Exit(1)
} }
err = c.Init()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := c.Ping(); err != nil { if err := c.Ping(); err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)

View file

@ -38,8 +38,8 @@ type WSClient struct {
} }
// Notification represents server-generated notification for client subscriptions. // Notification represents server-generated notification for client subscriptions.
// Value can be one of block.Block, result.ApplicationLog, result.NotificationEvent // Value can be one of block.Block, state.AppExecResult, state.NotificationEvent
// or transaction.Transaction based on Type. // transaction.Transaction or response.NotaryRequestEvent based on Type.
type Notification struct { type Notification struct {
Type response.EventID Type response.EventID
Value interface{} Value interface{}