diff --git a/consensus/consensus_validator.go b/consensus/consensus_validator.go index 122853754..783b86cfb 100644 --- a/consensus/consensus_validator.go +++ b/consensus/consensus_validator.go @@ -237,7 +237,7 @@ func (consensus *Consensus) processChallengeMessage(payload []byte) { log.Info("Failed to generate response", "err", err) return } - msgToSend := consensus.constructResponseMessage(response) + msgToSend := consensus.constructResponseMessage(proto_consensus.RESPONSE, response) p2p.SendMessage(consensus.leader, msgToSend) diff --git a/consensus/consensus_validator_msg.go b/consensus/consensus_validator_msg.go index c999adcc4..7172d2e8a 100644 --- a/consensus/consensus_validator_msg.go +++ b/consensus/consensus_validator_msg.go @@ -37,7 +37,7 @@ func (consensus *Consensus) constructCommitMessage(msgType proto_consensus.Messa } // Construct the response message to send to leader (assumption the consensus data is already verified) -func (consensus *Consensus) constructResponseMessage(response kyber.Scalar) []byte { +func (consensus *Consensus) constructResponseMessage(msgType proto_consensus.MessageType, response kyber.Scalar) []byte { buffer := bytes.NewBuffer([]byte{}) // 4 byte consensus id @@ -60,5 +60,5 @@ func (consensus *Consensus) constructResponseMessage(response kyber.Scalar) []by signature := consensus.signMessage(buffer.Bytes()) buffer.Write(signature) - return proto_consensus.ConstructConsensusMessage(proto_consensus.RESPONSE, buffer.Bytes()) + return proto_consensus.ConstructConsensusMessage(msgType, buffer.Bytes()) } diff --git a/consensus/consensus_validator_msg_test.go b/consensus/consensus_validator_msg_test.go index 6facaaccc..46430eee4 100644 --- a/consensus/consensus_validator_msg_test.go +++ b/consensus/consensus_validator_msg_test.go @@ -25,7 +25,7 @@ func TestConstructResponseMessage(test *testing.T) { validator := p2p.Peer{Ip: "3", Port: "5"} consensus := NewConsensus("1", "2", "0", []p2p.Peer{leader, validator}, leader) consensus.blockHash = [32]byte{} - msg := consensus.constructResponseMessage(crypto.Ed25519Curve.Scalar()) + msg := consensus.constructResponseMessage(consensus_proto.RESPONSE, crypto.Ed25519Curve.Scalar()) if len(msg) != 1+1+1+4+32+2+32+64 { test.Errorf("Response message is not constructed in the correct size: %d", len(msg))