TMSP -> ABCI

This commit is contained in:
Ethan Buchman
2017-01-12 15:53:32 -05:00
parent 3a55339114
commit c147b41013
38 changed files with 208 additions and 206 deletions

View File

@@ -1,32 +1,32 @@
package proxy
import (
tmspcli "github.com/tendermint/tmsp/client"
"github.com/tendermint/tmsp/types"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/types"
)
//----------------------------------------------------------------------------------------
// Enforce which tmsp msgs can be sent on a connection at the type level
// Enforce which abci msgs can be sent on a connection at the type level
type AppConnConsensus interface {
SetResponseCallback(tmspcli.Callback)
SetResponseCallback(abcicli.Callback)
Error() error
InitChainSync(validators []*types.Validator) (err error)
BeginBlockSync(hash []byte, header *types.Header) (err error)
AppendTxAsync(tx []byte) *tmspcli.ReqRes
AppendTxAsync(tx []byte) *abcicli.ReqRes
EndBlockSync(height uint64) (types.ResponseEndBlock, error)
CommitSync() (res types.Result)
}
type AppConnMempool interface {
SetResponseCallback(tmspcli.Callback)
SetResponseCallback(abcicli.Callback)
Error() error
CheckTxAsync(tx []byte) *tmspcli.ReqRes
CheckTxAsync(tx []byte) *abcicli.ReqRes
FlushAsync() *tmspcli.ReqRes
FlushAsync() *abcicli.ReqRes
FlushSync() error
}
@@ -41,19 +41,19 @@ type AppConnQuery interface {
}
//-----------------------------------------------------------------------------------------
// Implements AppConnConsensus (subset of tmspcli.Client)
// Implements AppConnConsensus (subset of abcicli.Client)
type appConnConsensus struct {
appConn tmspcli.Client
appConn abcicli.Client
}
func NewAppConnConsensus(appConn tmspcli.Client) *appConnConsensus {
func NewAppConnConsensus(appConn abcicli.Client) *appConnConsensus {
return &appConnConsensus{
appConn: appConn,
}
}
func (app *appConnConsensus) SetResponseCallback(cb tmspcli.Callback) {
func (app *appConnConsensus) SetResponseCallback(cb abcicli.Callback) {
app.appConn.SetResponseCallback(cb)
}
@@ -69,7 +69,7 @@ func (app *appConnConsensus) BeginBlockSync(hash []byte, header *types.Header) (
return app.appConn.BeginBlockSync(hash, header)
}
func (app *appConnConsensus) AppendTxAsync(tx []byte) *tmspcli.ReqRes {
func (app *appConnConsensus) AppendTxAsync(tx []byte) *abcicli.ReqRes {
return app.appConn.AppendTxAsync(tx)
}
@@ -82,19 +82,19 @@ func (app *appConnConsensus) CommitSync() (res types.Result) {
}
//------------------------------------------------
// Implements AppConnMempool (subset of tmspcli.Client)
// Implements AppConnMempool (subset of abcicli.Client)
type appConnMempool struct {
appConn tmspcli.Client
appConn abcicli.Client
}
func NewAppConnMempool(appConn tmspcli.Client) *appConnMempool {
func NewAppConnMempool(appConn abcicli.Client) *appConnMempool {
return &appConnMempool{
appConn: appConn,
}
}
func (app *appConnMempool) SetResponseCallback(cb tmspcli.Callback) {
func (app *appConnMempool) SetResponseCallback(cb abcicli.Callback) {
app.appConn.SetResponseCallback(cb)
}
@@ -102,7 +102,7 @@ func (app *appConnMempool) Error() error {
return app.appConn.Error()
}
func (app *appConnMempool) FlushAsync() *tmspcli.ReqRes {
func (app *appConnMempool) FlushAsync() *abcicli.ReqRes {
return app.appConn.FlushAsync()
}
@@ -110,18 +110,18 @@ func (app *appConnMempool) FlushSync() error {
return app.appConn.FlushSync()
}
func (app *appConnMempool) CheckTxAsync(tx []byte) *tmspcli.ReqRes {
func (app *appConnMempool) CheckTxAsync(tx []byte) *abcicli.ReqRes {
return app.appConn.CheckTxAsync(tx)
}
//------------------------------------------------
// Implements AppConnQuery (subset of tmspcli.Client)
// Implements AppConnQuery (subset of abcicli.Client)
type appConnQuery struct {
appConn tmspcli.Client
appConn abcicli.Client
}
func NewAppConnQuery(appConn tmspcli.Client) *appConnQuery {
func NewAppConnQuery(appConn abcicli.Client) *appConnQuery {
return &appConnQuery{
appConn: appConn,
}

View File

@@ -5,29 +5,29 @@ import (
"testing"
. "github.com/tendermint/go-common"
tmspcli "github.com/tendermint/tmsp/client"
"github.com/tendermint/tmsp/example/dummy"
"github.com/tendermint/tmsp/server"
"github.com/tendermint/tmsp/types"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy"
"github.com/tendermint/abci/server"
"github.com/tendermint/abci/types"
)
//----------------------------------------
type AppConnTest interface {
EchoAsync(string) *tmspcli.ReqRes
EchoAsync(string) *abcicli.ReqRes
FlushSync() error
InfoSync() (types.ResponseInfo, error)
}
type appConnTest struct {
appConn tmspcli.Client
appConn abcicli.Client
}
func NewAppConnTest(appConn tmspcli.Client) AppConnTest {
func NewAppConnTest(appConn abcicli.Client) AppConnTest {
return &appConnTest{appConn}
}
func (app *appConnTest) EchoAsync(msg string) *tmspcli.ReqRes {
func (app *appConnTest) EchoAsync(msg string) *abcicli.ReqRes {
return app.appConn.EchoAsync(msg)
}
@@ -54,7 +54,7 @@ func TestEcho(t *testing.T) {
}
defer s.Stop()
// Start client
cli, err := clientCreator.NewTMSPClient()
cli, err := clientCreator.NewABCIClient()
if err != nil {
Exit(err.Error())
}
@@ -78,7 +78,7 @@ func BenchmarkEcho(b *testing.B) {
}
defer s.Stop()
// Start client
cli, err := clientCreator.NewTMSPClient()
cli, err := clientCreator.NewABCIClient()
if err != nil {
Exit(err.Error())
}
@@ -107,7 +107,7 @@ func TestInfo(t *testing.T) {
}
defer s.Stop()
// Start client
cli, err := clientCreator.NewTMSPClient()
cli, err := clientCreator.NewABCIClient()
if err != nil {
Exit(err.Error())
}

View File

@@ -5,15 +5,15 @@ import (
"sync"
cfg "github.com/tendermint/go-config"
tmspcli "github.com/tendermint/tmsp/client"
"github.com/tendermint/tmsp/example/dummy"
nilapp "github.com/tendermint/tmsp/example/nil"
"github.com/tendermint/tmsp/types"
abcicli "github.com/tendermint/abci/client"
"github.com/tendermint/abci/example/dummy"
nilapp "github.com/tendermint/abci/example/nil"
"github.com/tendermint/abci/types"
)
// NewTMSPClient returns newly connected client
// NewABCIClient returns newly connected client
type ClientCreator interface {
NewTMSPClient() (tmspcli.Client, error)
NewABCIClient() (abcicli.Client, error)
}
//----------------------------------------------------
@@ -31,8 +31,8 @@ func NewLocalClientCreator(app types.Application) ClientCreator {
}
}
func (l *localClientCreator) NewTMSPClient() (tmspcli.Client, error) {
return tmspcli.NewLocalClient(l.mtx, l.app), nil
func (l *localClientCreator) NewABCIClient() (abcicli.Client, error) {
return abcicli.NewLocalClient(l.mtx, l.app), nil
}
//---------------------------------------------------------------
@@ -52,9 +52,9 @@ func NewRemoteClientCreator(addr, transport string, mustConnect bool) ClientCrea
}
}
func (r *remoteClientCreator) NewTMSPClient() (tmspcli.Client, error) {
func (r *remoteClientCreator) NewABCIClient() (abcicli.Client, error) {
// Run forever in a loop
remoteApp, err := tmspcli.NewClient(r.addr, r.transport, r.mustConnect)
remoteApp, err := abcicli.NewClient(r.addr, r.transport, r.mustConnect)
if err != nil {
return nil, fmt.Errorf("Failed to connect to proxy: %v", err)
}
@@ -66,7 +66,7 @@ func (r *remoteClientCreator) NewTMSPClient() (tmspcli.Client, error) {
func DefaultClientCreator(config cfg.Config) ClientCreator {
addr := config.GetString("proxy_app")
transport := config.GetString("tmsp")
transport := config.GetString("abci")
switch addr {
case "dummy":

View File

@@ -28,7 +28,7 @@ type Handshaker interface {
}
// a multiAppConn is made of a few appConns (mempool, consensus, query)
// and manages their underlying tmsp clients, including the handshake
// and manages their underlying abci clients, including the handshake
// which ensures the app and tendermint are synced.
// TODO: on app restart, clients must reboot together
type multiAppConn struct {
@@ -45,7 +45,7 @@ type multiAppConn struct {
clientCreator ClientCreator
}
// Make all necessary tmsp connections to the application
// Make all necessary abci connections to the application
func NewMultiAppConn(config cfg.Config, clientCreator ClientCreator, handshaker Handshaker) *multiAppConn {
multiAppConn := &multiAppConn{
config: config,
@@ -75,21 +75,21 @@ func (app *multiAppConn) OnStart() error {
app.BaseService.OnStart()
// query connection
querycli, err := app.clientCreator.NewTMSPClient()
querycli, err := app.clientCreator.NewABCIClient()
if err != nil {
return err
}
app.queryConn = NewAppConnQuery(querycli)
// mempool connection
memcli, err := app.clientCreator.NewTMSPClient()
memcli, err := app.clientCreator.NewABCIClient()
if err != nil {
return err
}
app.mempoolConn = NewAppConnMempool(memcli)
// consensus connection
concli, err := app.clientCreator.NewTMSPClient()
concli, err := app.clientCreator.NewABCIClient()
if err != nil {
return err
}