Giter VIP home page Giter VIP logo

go-nimiq-rpc's People

Contributors

redmaner avatar riptl avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

go-nimiq-rpc's Issues

Memory leak with HTTP response bodies

I was testing out this library in a production setting (upcoming Albatross visualizer) and I noticed the service was using 40 GB of memory an hour in :^)
Closing the http.Response.Bodys with defer fixed it.

Needs defer httpResp.Body.Close() (with error handling) on line 120

go-nimiq-rpc/client.go

Lines 116 to 120 in 5f3e3b4

httpResp, err := nc.Transport.RoundTrip(httpReq)
if err != nil {
return nil, err
}

Also, this check is wrong.
godoc:

// The http Client and Transport guarantee that Body is always
// non-nil, even on responses without a body or responses with
// a zero-length body. It is the caller's responsibility to
// close Body.

go-nimiq-rpc/client.go

Lines 129 to 132 in 5f3e3b4

// Check if HTTP body exists
if httpResp.Body == nil {
return nil, ErrRespBodyEmpty
}

Currency amounts should not be floats

Thanks a lot for creating a Go client for the Nimiq RPC interface. This will be helpful in the future!
I will be creating a few issues + PRs with suggestions with minor things I noticed.

Floating point numbers are prone to rounding errors (try python3 -c "print(0.1 + 0.2)" in your terminal). We make an effort to store currency amounts as integers where possible.

The types at

const lunaNimRate float64 = 100000.00000

and

type NIM float64

should be changed to int64s.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.