types: use mtx on PartSet.String()

This commit is contained in:
Ethan Buchman 2017-03-02 20:47:07 -05:00
parent 6456654307
commit 8ba79252c8
5 changed files with 20 additions and 15 deletions

View File

@ -122,6 +122,8 @@ func (rs RoundStepType) String() string {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Immutable when returned from ConsensusState.GetRoundState() // Immutable when returned from ConsensusState.GetRoundState()
// TODO: Actually, only the top pointer is copied,
// so access to field pointers is still racey
type RoundState struct { type RoundState struct {
Height int // Height we are working on Height int // Height we are working on
Round int Round int

View File

@ -1,7 +1,7 @@
package proxy package proxy
import ( import (
. "github.com/tendermint/go-common" cmn "github.com/tendermint/go-common"
cfg "github.com/tendermint/go-config" cfg "github.com/tendermint/go-config"
) )
@ -9,7 +9,7 @@ import (
// Tendermint's interface to the application consists of multiple connections // Tendermint's interface to the application consists of multiple connections
type AppConns interface { type AppConns interface {
Service cmn.Service
Mempool() AppConnMempool Mempool() AppConnMempool
Consensus() AppConnConsensus Consensus() AppConnConsensus
@ -32,7 +32,7 @@ type Handshaker interface {
// which ensures the app and tendermint are synced. // which ensures the app and tendermint are synced.
// TODO: on app restart, clients must reboot together // TODO: on app restart, clients must reboot together
type multiAppConn struct { type multiAppConn struct {
BaseService cmn.BaseService
config cfg.Config config cfg.Config
@ -52,7 +52,7 @@ func NewMultiAppConn(config cfg.Config, clientCreator ClientCreator, handshaker
handshaker: handshaker, handshaker: handshaker,
clientCreator: clientCreator, clientCreator: clientCreator,
} }
multiAppConn.BaseService = *NewBaseService(log, "multiAppConn", multiAppConn) multiAppConn.BaseService = *cmn.NewBaseService(log, "multiAppConn", multiAppConn)
return multiAppConn return multiAppConn
} }

View File

@ -66,17 +66,17 @@ func TestNetInfo(t *testing.T) {
// FIXME: This seems to trigger a race condition with client.Local // FIXME: This seems to trigger a race condition with client.Local
// go test -v -race . -run=DumpCons // go test -v -race . -run=DumpCons
// func TestDumpConsensusState(t *testing.T) { func TestDumpConsensusState(t *testing.T) {
// for i, c := range GetClients() { for i, c := range GetClients() {
// // FIXME: fix server so it doesn't panic on invalid input // FIXME: fix server so it doesn't panic on invalid input
// nc, ok := c.(client.NetworkClient) nc, ok := c.(client.NetworkClient)
// require.True(t, ok, "%d", i) require.True(t, ok, "%d", i)
// cons, err := nc.DumpConsensusState() cons, err := nc.DumpConsensusState()
// require.Nil(t, err, "%d: %+v", i, err) require.Nil(t, err, "%d: %+v", i, err)
// assert.NotEmpty(t, cons.RoundState) assert.NotEmpty(t, cons.RoundState)
// assert.Empty(t, cons.PeerRoundStates) assert.Empty(t, cons.PeerRoundStates)
// } }
// } }
func TestGenesisAndValidators(t *testing.T) { func TestGenesisAndValidators(t *testing.T) {
for i, c := range GetClients() { for i, c := range GetClients() {

View File

@ -16,6 +16,7 @@ func ABCIQuery(path string, data []byte, prove bool) (*ctypes.ResultABCIQuery, e
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Info("ABCIQuery", "path", path, "data", data, "result", resQuery)
return &ctypes.ResultABCIQuery{resQuery}, nil return &ctypes.ResultABCIQuery{resQuery}, nil
} }

View File

@ -268,6 +268,8 @@ func (ps *PartSet) StringShort() string {
if ps == nil { if ps == nil {
return "nil-PartSet" return "nil-PartSet"
} else { } else {
ps.mtx.Lock()
defer ps.mtx.Unlock()
return fmt.Sprintf("(%v of %v)", ps.Count(), ps.Total()) return fmt.Sprintf("(%v of %v)", ps.Count(), ps.Total())
} }
} }