@ -6,8 +6,8 @@ import (
"sync"
"sync"
"time"
"time"
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
"golang.org/x/net/context"
"google.golang.org/grpc"
"github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tendermint/libs/common"
cmn "github.com/tendermint/tendermint/libs/common"
@ -39,7 +39,7 @@ func NewGRPCClient(addr string, mustConnect bool) *grpcClient {
return cli
return cli
}
}
func dialerFunc ( addr string , timeout time . Duration ) ( net . Conn , error ) {
func dialerFunc ( ctx context . Context , addr string ) ( net . Conn , error ) {
return cmn . Connect ( addr )
return cmn . Connect ( addr )
}
}
@ -49,7 +49,7 @@ func (cli *grpcClient) OnStart() error {
}
}
RETRY_LOOP :
RETRY_LOOP :
for {
for {
conn , err := grpc . Dial ( cli . addr , grpc . WithInsecure ( ) , grpc . WithDialer ( dialerFunc ) )
conn , err := grpc . Dial ( cli . addr , grpc . WithInsecure ( ) , grpc . WithContext Dialer ( dialerFunc ) )
if err != nil {
if err != nil {
if cli . mustConnect {
if cli . mustConnect {
return err
return err
@ -65,7 +65,7 @@ RETRY_LOOP:
ENSURE_CONNECTED :
ENSURE_CONNECTED :
for {
for {
_ , err := client . Echo ( context . Background ( ) , & types . RequestEcho { Message : "hello" } , grpc . FailFast ( true ) )
_ , err := client . Echo ( context . Background ( ) , & types . RequestEcho { Message : "hello" } , grpc . WaitForReady ( true ) )
if err == nil {
if err == nil {
break ENSURE_CONNECTED
break ENSURE_CONNECTED
}
}
@ -125,7 +125,7 @@ func (cli *grpcClient) SetResponseCallback(resCb Callback) {
func ( cli * grpcClient ) EchoAsync ( msg string ) * ReqRes {
func ( cli * grpcClient ) EchoAsync ( msg string ) * ReqRes {
req := types . ToRequestEcho ( msg )
req := types . ToRequestEcho ( msg )
res , err := cli . client . Echo ( context . Background ( ) , req . GetEcho ( ) , grpc . FailFast ( true ) )
res , err := cli . client . Echo ( context . Background ( ) , req . GetEcho ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -134,7 +134,7 @@ func (cli *grpcClient) EchoAsync(msg string) *ReqRes {
func ( cli * grpcClient ) FlushAsync ( ) * ReqRes {
func ( cli * grpcClient ) FlushAsync ( ) * ReqRes {
req := types . ToRequestFlush ( )
req := types . ToRequestFlush ( )
res , err := cli . client . Flush ( context . Background ( ) , req . GetFlush ( ) , grpc . FailFast ( true ) )
res , err := cli . client . Flush ( context . Background ( ) , req . GetFlush ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -143,7 +143,7 @@ func (cli *grpcClient) FlushAsync() *ReqRes {
func ( cli * grpcClient ) InfoAsync ( params types . RequestInfo ) * ReqRes {
func ( cli * grpcClient ) InfoAsync ( params types . RequestInfo ) * ReqRes {
req := types . ToRequestInfo ( params )
req := types . ToRequestInfo ( params )
res , err := cli . client . Info ( context . Background ( ) , req . GetInfo ( ) , grpc . FailFast ( true ) )
res , err := cli . client . Info ( context . Background ( ) , req . GetInfo ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -152,7 +152,7 @@ func (cli *grpcClient) InfoAsync(params types.RequestInfo) *ReqRes {
func ( cli * grpcClient ) SetOptionAsync ( params types . RequestSetOption ) * ReqRes {
func ( cli * grpcClient ) SetOptionAsync ( params types . RequestSetOption ) * ReqRes {
req := types . ToRequestSetOption ( params )
req := types . ToRequestSetOption ( params )
res , err := cli . client . SetOption ( context . Background ( ) , req . GetSetOption ( ) , grpc . FailFast ( true ) )
res , err := cli . client . SetOption ( context . Background ( ) , req . GetSetOption ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -161,7 +161,7 @@ func (cli *grpcClient) SetOptionAsync(params types.RequestSetOption) *ReqRes {
func ( cli * grpcClient ) DeliverTxAsync ( params types . RequestDeliverTx ) * ReqRes {
func ( cli * grpcClient ) DeliverTxAsync ( params types . RequestDeliverTx ) * ReqRes {
req := types . ToRequestDeliverTx ( params )
req := types . ToRequestDeliverTx ( params )
res , err := cli . client . DeliverTx ( context . Background ( ) , req . GetDeliverTx ( ) , grpc . FailFast ( true ) )
res , err := cli . client . DeliverTx ( context . Background ( ) , req . GetDeliverTx ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -170,7 +170,7 @@ func (cli *grpcClient) DeliverTxAsync(params types.RequestDeliverTx) *ReqRes {
func ( cli * grpcClient ) CheckTxAsync ( params types . RequestCheckTx ) * ReqRes {
func ( cli * grpcClient ) CheckTxAsync ( params types . RequestCheckTx ) * ReqRes {
req := types . ToRequestCheckTx ( params )
req := types . ToRequestCheckTx ( params )
res , err := cli . client . CheckTx ( context . Background ( ) , req . GetCheckTx ( ) , grpc . FailFast ( true ) )
res , err := cli . client . CheckTx ( context . Background ( ) , req . GetCheckTx ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -179,7 +179,7 @@ func (cli *grpcClient) CheckTxAsync(params types.RequestCheckTx) *ReqRes {
func ( cli * grpcClient ) QueryAsync ( params types . RequestQuery ) * ReqRes {
func ( cli * grpcClient ) QueryAsync ( params types . RequestQuery ) * ReqRes {
req := types . ToRequestQuery ( params )
req := types . ToRequestQuery ( params )
res , err := cli . client . Query ( context . Background ( ) , req . GetQuery ( ) , grpc . FailFast ( true ) )
res , err := cli . client . Query ( context . Background ( ) , req . GetQuery ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -188,7 +188,7 @@ func (cli *grpcClient) QueryAsync(params types.RequestQuery) *ReqRes {
func ( cli * grpcClient ) CommitAsync ( ) * ReqRes {
func ( cli * grpcClient ) CommitAsync ( ) * ReqRes {
req := types . ToRequestCommit ( )
req := types . ToRequestCommit ( )
res , err := cli . client . Commit ( context . Background ( ) , req . GetCommit ( ) , grpc . FailFast ( true ) )
res , err := cli . client . Commit ( context . Background ( ) , req . GetCommit ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -197,7 +197,7 @@ func (cli *grpcClient) CommitAsync() *ReqRes {
func ( cli * grpcClient ) InitChainAsync ( params types . RequestInitChain ) * ReqRes {
func ( cli * grpcClient ) InitChainAsync ( params types . RequestInitChain ) * ReqRes {
req := types . ToRequestInitChain ( params )
req := types . ToRequestInitChain ( params )
res , err := cli . client . InitChain ( context . Background ( ) , req . GetInitChain ( ) , grpc . FailFast ( true ) )
res , err := cli . client . InitChain ( context . Background ( ) , req . GetInitChain ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -206,7 +206,7 @@ func (cli *grpcClient) InitChainAsync(params types.RequestInitChain) *ReqRes {
func ( cli * grpcClient ) BeginBlockAsync ( params types . RequestBeginBlock ) * ReqRes {
func ( cli * grpcClient ) BeginBlockAsync ( params types . RequestBeginBlock ) * ReqRes {
req := types . ToRequestBeginBlock ( params )
req := types . ToRequestBeginBlock ( params )
res , err := cli . client . BeginBlock ( context . Background ( ) , req . GetBeginBlock ( ) , grpc . FailFast ( true ) )
res , err := cli . client . BeginBlock ( context . Background ( ) , req . GetBeginBlock ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}
@ -215,7 +215,7 @@ func (cli *grpcClient) BeginBlockAsync(params types.RequestBeginBlock) *ReqRes {
func ( cli * grpcClient ) EndBlockAsync ( params types . RequestEndBlock ) * ReqRes {
func ( cli * grpcClient ) EndBlockAsync ( params types . RequestEndBlock ) * ReqRes {
req := types . ToRequestEndBlock ( params )
req := types . ToRequestEndBlock ( params )
res , err := cli . client . EndBlock ( context . Background ( ) , req . GetEndBlock ( ) , grpc . FailFast ( true ) )
res , err := cli . client . EndBlock ( context . Background ( ) , req . GetEndBlock ( ) , grpc . WaitForReady ( true ) )
if err != nil {
if err != nil {
cli . StopForError ( err )
cli . StopForError ( err )
}
}