Skip to content

Network tweaks

Luke Champine requested to merge net into master

NetAddress is now just Address, and it's a string. Most of the standard library network functions operate on strings, and this also means we don't have to perform ugly int -> string conversion all over the place.

RPC internals have been tweaked a bit; functionality is not affected. I also implemented a proper "ping-pong" RPC, so you can be confident that an address for which Ping() returns true is a potential peer.

Next priority, network-wise, is properly handling RPC errors. There will probably be a lot of logic changes bundled with that, because the ability to check for errors gives you the option to resend, try another peer, etc. However, it's important to keep in mind that error messages can be falsified. So the code should not branch on errors in a way that is attackable.

Finally, I was thinking about it the other night and I'm pretty sure I could make RPC functions return a value instead of modifying a pointer. e.g.:

func RPCfoo(arg string, response *string) error {
    *response = "foo"
    return nil
}
// becomes
func RPCfoo(arg string) (string, error) {
    return "foo", nil
}

If you think this is cleaner/clearer, I could likely include it in this PR.

Merge request reports