api: (breaking change) provide contract code non-hex encoded to save bandwidth and cpu
package api
import (
+ "bytes"
"context"
"encoding/hex"
"fmt"
@@ -36,7 +37,6 @@ import (
"net/http"
"net/url"
"strconv"
- "strings"
"time"
)
@@ -422,9 +422,9 @@ func (g *Gateway) getContractCode(ctx *fasthttp.RequestCtx) {
ctx.Response.Header.Set("Content-Disposition", "attachment; filename="+hex.EncodeToString(id[:])+".wasm")
ctx.Response.Header.Set("Content-Type", "application/wasm")
- ctx.Response.Header.Set("Content-Length", strconv.Itoa(hex.EncodedLen(len(code))))
+ ctx.Response.Header.Set("Content-Length", strconv.Itoa(len(code)))
- _, _ = io.Copy(ctx, strings.NewReader(hex.EncodeToString(code)))
+ _, _ = io.Copy(ctx, bytes.NewReader(code))
}
func (g *Gateway) getContractPages(ctx *fasthttp.RequestCtx) {
