Skip to content

Merge network into gateway (plus new RPCs)

Luke Champine requested to merge newrpc into master

All network package functionality is now handled by the gateway.

RPCs must now have the function signature func(modules.NetConn) error (meaning: no more reflection!). Internally, the gateway uses a new monitored connection type that satisfies the modules.NetConn interface. This allows the gateway to terminate malicious-seeming connections and blacklist them. (Oh right, peers can be blacklisted now -- well, sort of. After a number of "strikes" they get removed from the peer list, but there's nothing preventing them from being added again). The logic that identifies a connection as "malicious" has not yet been implemented.

Gateway-specific RPCs like SharePeers and AddMe have been moved out of the Gateway interface and into the concrete type, along with the RPCs that the network used to own, like Ping.

The gateway package now stands at 78% test coverage, woo!

Notes:

  • The relayBlock and acceptTransaction functions in daemon.go are temporary, and should be moved to their respective modules when the time comes.
  • I tried creating a GatewayTester so that other modules wouldn't have to manage their own RPC ports, but I ran into problems. During testing, each module loads the gateway separately, so the port counter gets reset. So the only way to avoid port conflicts is to enforce that all tests must Close the gateway when they complete. We can still do this, but for now I felt it wasn't worth the effort.

Merge request reports