github.com/Oyster-zx/tendermint@v0.34.24-fork/rpc/grpc/api.go (about) 1 package coregrpc 2 3 import ( 4 "context" 5 6 abci "github.com/tendermint/tendermint/abci/types" 7 core "github.com/tendermint/tendermint/rpc/core" 8 rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types" 9 ) 10 11 type broadcastAPI struct { 12 } 13 14 func (bapi *broadcastAPI) Ping(ctx context.Context, req *RequestPing) (*ResponsePing, error) { 15 // kvstore so we can check if the server is up 16 return &ResponsePing{}, nil 17 } 18 19 func (bapi *broadcastAPI) BroadcastTx(ctx context.Context, req *RequestBroadcastTx) (*ResponseBroadcastTx, error) { 20 // NOTE: there's no way to get client's remote address 21 // see https://stackoverflow.com/questions/33684570/session-and-remote-ip-address-in-grpc-go 22 res, err := core.BroadcastTxCommit(&rpctypes.Context{}, req.Tx) 23 if err != nil { 24 return nil, err 25 } 26 27 return &ResponseBroadcastTx{ 28 CheckTx: &abci.ResponseCheckTx{ 29 Code: res.CheckTx.Code, 30 Data: res.CheckTx.Data, 31 Log: res.CheckTx.Log, 32 }, 33 DeliverTx: &abci.ResponseDeliverTx{ 34 Code: res.DeliverTx.Code, 35 Data: res.DeliverTx.Data, 36 Log: res.DeliverTx.Log, 37 }, 38 }, nil 39 }