mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-03 03:35:19 +00:00
Closes https://github.com/tendermint/tendermint/issues/3857 Moves `lib/` folder to `jsonrpc/`. Renames: **packages** `rpc` package -> `jsonrpc` package `rpcclient` package -> `client` package `rpcserver` package -> `server` package **structs and interfaces** ``` JSONRPCClient to Client JSONRPCRequestBatch to RequestBatch JSONRPCCaller to Caller ``` **functions** ``` StartHTTPServer to Serve StartHTTPAndTLSServer to ServeTLS rpc/jsonrpc/client: rename NewURIClient to NewURI NewJSONRPCClient to New NewJSONRPCClientWithHTTPClient to NewWithHTTPClient NewWSClient to NewWS ``` **misc** - unexpose `ResponseWriterWrapper` - remove unused http_params.go
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package coregrpc
|
|
|
|
import (
|
|
"context"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
core "github.com/tendermint/tendermint/rpc/core"
|
|
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
|
)
|
|
|
|
type broadcastAPI struct {
|
|
}
|
|
|
|
func (bapi *broadcastAPI) Ping(ctx context.Context, req *RequestPing) (*ResponsePing, error) {
|
|
// kvstore so we can check if the server is up
|
|
return &ResponsePing{}, nil
|
|
}
|
|
|
|
func (bapi *broadcastAPI) BroadcastTx(ctx context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) {
|
|
// NOTE: there's no way to get client's remote address
|
|
// see https://stackoverflow.com/questions/33684570/session-and-remote-ip-address-in-grpc-go
|
|
res, err := core.BroadcastTxCommit(&rpctypes.Context{}, req.Tx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &ResponseBroadcastTx{
|
|
CheckTx: &abci.ResponseCheckTx{
|
|
Code: res.CheckTx.Code,
|
|
Data: res.CheckTx.Data,
|
|
Log: res.CheckTx.Log,
|
|
},
|
|
DeliverTx: &abci.ResponseDeliverTx{
|
|
Code: res.DeliverTx.Code,
|
|
Data: res.DeliverTx.Data,
|
|
Log: res.DeliverTx.Log,
|
|
},
|
|
}, nil
|
|
}
|