Browse Source

types: use mtx on PartSet.String()

pull/422/head
Ethan Buchman 8 years ago
parent
commit
8ba79252c8
5 changed files with 20 additions and 15 deletions
  1. +2
    -0
      consensus/state.go
  2. +4
    -4
      proxy/multi_app_conn.go
  3. +11
    -11
      rpc/client/rpc_test.go
  4. +1
    -0
      rpc/core/abci.go
  5. +2
    -0
      types/part_set.go

+ 2
- 0
consensus/state.go View File

@ -122,6 +122,8 @@ func (rs RoundStepType) String() string {
//-----------------------------------------------------------------------------
// 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 {
Height int // Height we are working on
Round int


+ 4
- 4
proxy/multi_app_conn.go View File

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


+ 11
- 11
rpc/client/rpc_test.go View File

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


+ 1
- 0
rpc/core/abci.go View File

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


+ 2
- 0
types/part_set.go View File

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

Loading…
Cancel
Save