예제 #1
0
파일: node.go 프로젝트: eris-ltd/tendermint
// Get a connection to the proxyAppConn addr.
// Check the current hash, and panic if it doesn't match.
func GetProxyApp(addr string, hash []byte) (proxyAppConn proxy.AppConn) {
	// use local app (for testing)
	switch addr {
	case "nilapp":
		app := nilapp.NewNilApplication()
		mtx := new(sync.Mutex)
		proxyAppConn = tmspcli.NewLocalClient(mtx, app)
	case "dummy":
		app := dummy.NewDummyApplication()
		mtx := new(sync.Mutex)
		proxyAppConn = tmspcli.NewLocalClient(mtx, app)
	default:
		// Run forever in a loop
		remoteApp, err := proxy.NewRemoteAppConn(addr)
		if err != nil {
			Exit(Fmt("Failed to connect to proxy for mempool: %v", err))
		}
		proxyAppConn = remoteApp
	}

	// Check the hash
	res := proxyAppConn.CommitSync()
	if res.IsErr() {
		PanicCrisis(Fmt("Error in getting proxyAppConn hash: %v", res))
	}
	if !bytes.Equal(hash, res.Data) {
		log.Warn(Fmt("ProxyApp hash does not match.  Expected %X, got %X", hash, res.Data))
	}

	return proxyAppConn
}
예제 #2
0
func NewLocalClient() *Client {
	eyesApp := app.NewMerkleEyesApp()
	tmspClient := tmspcli.NewLocalClient(nil, eyesApp)
	return &Client{
		Client: tmspClient,
	}
}
예제 #3
0
func newConsensusState(state *sm.State, pv *types.PrivValidator, app tmsp.Application) *ConsensusState {
	// Get BlockStore
	blockDB := dbm.NewMemDB()
	blockStore := bc.NewBlockStore(blockDB)

	// one for mempool, one for consensus
	mtx := new(sync.Mutex)
	proxyAppConnMem := tmspcli.NewLocalClient(mtx, app)
	proxyAppConnCon := tmspcli.NewLocalClient(mtx, app)

	// Make Mempool
	mempool := mempl.NewMempool(config, proxyAppConnMem)

	// Make ConsensusReactor
	cs := NewConsensusState(config, state, proxyAppConnCon, blockStore, mempool)
	cs.SetPrivValidator(pv)

	evsw := events.NewEventSwitch()
	cs.SetEventSwitch(evsw)
	evsw.Start()
	return cs
}