// RequestToPeer opens a stream to a single peer and sends a proto request.
RequestToPeer opens a stream to a single peer and sends a proto request.
// RequestToPeer opens a stream to a single peer and sends a proto request .
func (rpc *RPC) RequestToPeer(peerID peer.ID, method string) (*pb.Response, error) {
	stream, err := rpc.lnode.NewStream(rpc.lnode.GetContext(), peerID, rpc.RequestID())
	if err != nil {
		return nil, err
	}
	writer := bufio.NewWriter(stream)
	requestPayload := rpc.createReq(method)
	enc := protobufCodec.Multicodec(nil).Encoder(writer)
	if err = enc.Encode(requestPayload); err != nil {
		return nil, err
	}
	writer.Flush()
	reqResp := rpc.registerReqOut(requestPayload)
	respPb := <-reqResp.respChan
	return respPb, nil
}
func ( rpc * RPC ) RequestToPeer ( peerID peer . ID , method string ) ( * pb . Response , error ) { stream , err := rpc . lnode . NewStream ( rpc . lnode . GetContext ( ) , peerID , rpc . RequestID ( ) ) if err != nil { return nil , err } writer := bufio . NewWriter ( stream ) requestPayload := rpc . createReq ( method ) enc := protobufCodec . Multicodec ( nil ) . Encoder ( writer ) if err = enc . Encode ( requestPayload ) ; err != nil { return nil , err } writer . Flush ( ) reqResp := rpc . registerReqOut ( requestPayload ) respPb := <- reqResp . respChan return respPb , nil }
RequestToPeer opens a stream to a single peer and sends a proto request.
RequestToPeer opens a stream to a single peer and sends a proto request .