forward forwards the rpc to the passed target node.
(target, method string, args interface{}, reply interface{})
| 101 | |
| 102 | // forward forwards the rpc to the passed target node. |
| 103 | func (r *rpcServer) forward(target, method string, args interface{}, reply interface{}) error { |
| 104 | r.n.lock.Lock() |
| 105 | p, ok := r.n.nodes[target] |
| 106 | r.n.lock.Unlock() |
| 107 | if !ok { |
| 108 | return fmt.Errorf("could not dial unknown peer %v", target) |
| 109 | } |
| 110 | |
| 111 | addr, err := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%d", p.addr, p.port)) |
| 112 | if err != nil { |
| 113 | return fmt.Errorf("Failed to resolve tcp address of peer %v: %v", target, err) |
| 114 | } |
| 115 | |
| 116 | err = r.connPool.RPC(addr, method, args, reply) |
| 117 | return err |
| 118 | } |
| 119 | |
| 120 | // StorageArgs is the struct used to make data related RPC calls. |
| 121 | type StorageArgs struct { |