func (g *Gateway) UnregisterRPC(name string) {
	g.mu.Lock()
	defer g.mu.Unlock()
	if _, ok := g.handlers[handlerName(name)]; !ok {
		build.Critical("RPC not registered: " + name)
	}
	delete(g.handlers, handlerName(name))
}
UnregisterRPC unregisters an RPC and removes the corresponding RPCFunc from
g.handlers. Future calls to the RPC by peers will fail.
package gateway
import (
	"errors"
	"sync"
	"time"
	"github.com/NebulousLabs/Sia/build"
	"github.com/NebulousLabs/Sia/encoding"
	"github.com/NebulousLabs/Sia/modules"
)
type rpcID [8]byte
func (id rpcID) String() string {
	for i := range id {
		if id[i] == 0 {
			id[i] = ' '
		}
	}
	return string(id[:])
}
func handlerName(name string) (id rpcID) {
	copy(id[:], name)
	return
}
func (g *Gateway) managedRPC(addr modules.NetAddress, name string, fn modules.RPCFunc) error {
	g.mu.RLock()
	peer, ok := g.peers[addr]
	g.mu.RUnlock()
	if !ok {
		return errors.New("can't call RPC on unconnected peer " + string(addr))
	}
	conn, err := peer.open()
	if err != nil {
		g.log.Debugf("Could not initiate RPC with %v; disconnecting", addr)
		peer.sess.Close()
		g.mu.Lock()
		delete(g.peers, addr)
		g.mu.Unlock()
		return err
	}
	defer conn.Close()
	conn.SetDeadline(time.Now().Add(rpcStdDeadline))
	if err := encoding.WriteObject(conn, handlerName(name)); err != nil {
		return err
	}
	conn.SetDeadline(time.Time{})
	return fn(conn)
}
func (g *Gateway) RPC(addr modules.NetAddress, name string, fn modules.RPCFunc) error {
	if err := g.threads.Add(); err != nil {
		return err
	}
	defer g.threads.Done()
	return g.managedRPC(addr, name, fn)
}
func (g *Gateway) RegisterRPC(name string, fn modules.RPCFunc) {
	g.mu.Lock()
	defer g.mu.Unlock()
	if _, ok := g.handlers[handlerName(name)]; ok {
		build.Critical("RPC already registered: " + name)
	}
	g.handlers[handlerName(name)] = fn
}