forked from TrueCloudLab/neoneo-go
Merge pull request #1998 from nspcc-dev/fix-calculatenetworkfee-result
rpc: wrap calculatenetworkfee result in a structure
This commit is contained in:
commit
a6fc5d9fe4
3 changed files with 10 additions and 4 deletions
|
@ -34,12 +34,12 @@ var errNetworkNotInitialized = errors.New("RPC client network is not initialized
|
||||||
func (c *Client) CalculateNetworkFee(tx *transaction.Transaction) (int64, error) {
|
func (c *Client) CalculateNetworkFee(tx *transaction.Transaction) (int64, error) {
|
||||||
var (
|
var (
|
||||||
params = request.NewRawParams(tx.Bytes())
|
params = request.NewRawParams(tx.Bytes())
|
||||||
resp int64
|
resp = new(result.NetworkFee)
|
||||||
)
|
)
|
||||||
if err := c.performRequest("calculatenetworkfee", params, &resp); err != nil {
|
if err := c.performRequest("calculatenetworkfee", params, resp); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
return resp, nil
|
return resp.Value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetApplicationLog returns the contract log based on the specified txid.
|
// GetApplicationLog returns the contract log based on the specified txid.
|
||||||
|
|
6
pkg/rpc/response/result/netfee.go
Normal file
6
pkg/rpc/response/result/netfee.go
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package result
|
||||||
|
|
||||||
|
// NetworkFee represents a result of calculatenetworkfee RPC call.
|
||||||
|
type NetworkFee struct {
|
||||||
|
Value int64 `json:"networkfee,string"`
|
||||||
|
}
|
|
@ -634,7 +634,7 @@ func (s *Server) calculateNetworkFee(reqParams request.Params) (interface{}, *re
|
||||||
}
|
}
|
||||||
fee := s.chain.GetPolicer().FeePerByte()
|
fee := s.chain.GetPolicer().FeePerByte()
|
||||||
netFee += int64(size) * fee
|
netFee += int64(size) * fee
|
||||||
return netFee, nil
|
return result.NetworkFee{Value: netFee}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getApplicationLog returns the contract log based on the specified txid or blockid.
|
// getApplicationLog returns the contract log based on the specified txid or blockid.
|
||||||
|
|
Loading…
Reference in a new issue