Optimizations + some improvements (#105)
* Optimizations + some improvements - optimized pkg/core/storage.HeaderHashes - optimized pkg/rpc.performRequest (used json.Encoder) - fixes for pkg/util.ReadVarUint and pkg/util.WriteVarUint - optimized and fix fixed8 (Fixed8DecodeString / MarshalJSON) + tests - optimized and fix uint160 (Bytes / Uint160DecodeString / Equal / MarshalJSON) + tests - optimized and fix uint256 (Bytes / Equal / MarshalJSON) + tests - preallocate for pkg/vm.buildStackOutput - add go.mod / go.sum * update version
This commit is contained in:
parent
c8d7671d26
commit
6ccb518ab0
14 changed files with 205 additions and 101 deletions
|
@ -83,18 +83,21 @@ func NewClient(ctx context.Context, endpoint string, opts ClientOptions) (*Clien
|
|||
}
|
||||
|
||||
func (c *Client) performRequest(method string, p params, v interface{}) error {
|
||||
r := request{
|
||||
JSONRPC: c.version,
|
||||
Method: method,
|
||||
Params: p.values,
|
||||
ID: 1,
|
||||
}
|
||||
var (
|
||||
r = request{
|
||||
JSONRPC: c.version,
|
||||
Method: method,
|
||||
Params: p.values,
|
||||
ID: 1,
|
||||
}
|
||||
buf = new(bytes.Buffer)
|
||||
)
|
||||
|
||||
b, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
if err := json.NewEncoder(buf).Encode(r); err != nil {
|
||||
return err
|
||||
}
|
||||
req, err := http.NewRequest("POST", c.endpoint.String(), bytes.NewReader(b))
|
||||
|
||||
req, err := http.NewRequest("POST", c.endpoint.String(), buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue