Skip to content

Commit

Permalink
switch Reply type in socket for other messages
Browse files Browse the repository at this point in the history
 - add error description on error
  • Loading branch information
liamsi committed Sep 21, 2018
1 parent ceb860c commit 7c8375c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/tendermint/commands/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func initFilesWithConfig(config *cfg.Config) error {
}
genDoc.Validators = []types.GenesisValidator{{
Address: pv.GetPubKey().Address(),
PubKey: pv.GetPubKey(),
Power: 10,
PubKey: pv.GetPubKey(),
Power: 10,
}}

if err := genDoc.SaveAs(genFile); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/tendermint/commands/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ func testnetFiles(cmd *cobra.Command, args []string) error {
pv := privval.LoadFilePV(pvFile)
genVals[i] = types.GenesisValidator{
Address: pv.GetPubKey().Address(),
PubKey: pv.GetPubKey(),
Power: 1,
Name: nodeDirName,
PubKey: pv.GetPubKey(),
Power: 1,
Name: nodeDirName,
}
}

Expand Down
1 change: 0 additions & 1 deletion consensus/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func PrometheusMetrics() *Metrics {
Help: "Total power of the byzantine validators.",
}, []string{}),


BlockIntervalSeconds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Subsystem: "consensus",
Name: "block_interval_seconds",
Expand Down
1 change: 0 additions & 1 deletion consensus/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,6 @@ func (cs *ConsensusState) createProposalBlock() (block *types.Block, blockParts
return block, parts
}


// Enter: `timeoutPropose` after entering Propose.
// Enter: proposal block and POL is ready.
// Enter: any +2/3 prevotes for future round.
Expand Down
17 changes: 13 additions & 4 deletions privval/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (sc *SocketPV) SignProposal(
return err
}

*proposal = *res.(*SignProposalRequest).Proposal
*proposal = *res.(*SignedProposalReply).Proposal

return nil
}
Expand All @@ -200,7 +200,7 @@ func (sc *SocketPV) SignHeartbeat(
return err
}

*heartbeat = *res.(*SignHeartbeatRequest).Heartbeat
*heartbeat = *res.(*SignedHeartbeatReply).Heartbeat

return nil
}
Expand Down Expand Up @@ -472,10 +472,18 @@ func (rs *RemoteSigner) handleConnection(conn net.Conn) {

case *SignProposalRequest:
err = rs.privVal.SignProposal(rs.chainID, r.Proposal)
res = &SignProposalRequest{r.Proposal}
if err != nil {
res = &SignedProposalReply{r.Proposal, &Error{0, err.Error()}}
} else {
res = &SignedProposalReply{r.Proposal, nil}
}
case *SignHeartbeatRequest:
err = rs.privVal.SignHeartbeat(rs.chainID, r.Heartbeat)
res = &SignHeartbeatRequest{r.Heartbeat}
if err != nil {
res = &SignedHeartbeatReply{r.Heartbeat, &Error{0, err.Error()}}
} else {
res = &SignedHeartbeatReply{r.Heartbeat, nil}
}
default:
err = fmt.Errorf("unknown msg: %v", r)
}
Expand Down Expand Up @@ -547,6 +555,7 @@ type SignedHeartbeatReply struct {

// Error allows (remote) validators to include meaningful error descriptions in their reply.
type Error struct {
// TODO(ismail): create an enum of known errors
Code int
Description string
}
Expand Down

0 comments on commit 7c8375c

Please sign in to comment.