temp fix for enabling travis

pull/5/head
Richard Liu 7 years ago
parent 1e513669e3
commit 7bd78e56a2
  1. 2
      aws-code/dial.go
  2. 2
      aws-code/listen.go
  3. 6
      consensus/consensus_leader.go
  4. 36
      consensus/consensus_validator.go

@ -6,7 +6,7 @@ import (
"net" "net"
) )
func main() { func dialMain() { // TODO: temp fix to unblock test
conn, err := net.Dial("tcp", ":9000") conn, err := net.Dial("tcp", ":9000")
if err != nil { if err != nil {
panic(err) panic(err)

@ -7,7 +7,7 @@ import (
"time" "time"
) )
func main() { func listenMain() { // TODO: temp fix to unblock test
ln, err := net.Listen("tcp", "localhost:9000") ln, err := net.Listen("tcp", "localhost:9000")
if err != nil { if err != nil {
panic(err) panic(err)

@ -39,17 +39,17 @@ func (consensus *Consensus) ProcessMessageLeader(message []byte) {
log.Printf("[Leader] Received and processing message: %s\n", msgType) log.Printf("[Leader] Received and processing message: %s\n", msgType)
switch msgType { switch msgType {
case ANNOUNCE: case ANNOUNCE:
log.Println("Unexpected message type: %s", msgType) log.Printf("Unexpected message type: %s", msgType)
case COMMIT: case COMMIT:
consensus.processCommitMessage(payload) consensus.processCommitMessage(payload)
case CHALLENGE: case CHALLENGE:
log.Println("Unexpected message type: %s", msgType) log.Printf("Unexpected message type: %s", msgType)
case RESPONSE: case RESPONSE:
consensus.processResponseMessage(payload) consensus.processResponseMessage(payload)
case START_CONSENSUS: case START_CONSENSUS:
consensus.processStartConsensusMessage(payload) consensus.processStartConsensusMessage(payload)
default: default:
log.Println("Unexpected message type: %s", msgType) log.Printf("Unexpected message type: %s", msgType)
} }
} }

@ -1,10 +1,10 @@
package consensus package consensus
import ( import (
"harmony-benchmark/p2p"
"log"
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"harmony-benchmark/p2p"
"log"
) )
// Validator's consensus message dispatcher // Validator's consensus message dispatcher
@ -24,13 +24,13 @@ func (consensus *Consensus) ProcessMessageValidator(message []byte) {
case ANNOUNCE: case ANNOUNCE:
consensus.processAnnounceMessage(payload) consensus.processAnnounceMessage(payload)
case COMMIT: case COMMIT:
log.Println("Unexpected message type: %s", msgType) log.Printf("Unexpected message type: %s", msgType)
case CHALLENGE: case CHALLENGE:
consensus.processChallengeMessage(payload) consensus.processChallengeMessage(payload)
case RESPONSE: case RESPONSE:
log.Println("Unexpected message type: %s", msgType) log.Printf("Unexpected message type: %s", msgType)
default: default:
log.Println("Unexpected message type: %s", msgType) log.Printf("Unexpected message type: %s", msgType)
} }
} }
@ -38,28 +38,28 @@ func (consensus *Consensus) processAnnounceMessage(payload []byte) {
//#### Read payload data //#### Read payload data
offset := 0 offset := 0
// 4 byte consensus id // 4 byte consensus id
consensusId := binary.BigEndian.Uint32(payload[offset:offset+4]) consensusId := binary.BigEndian.Uint32(payload[offset : offset+4])
offset += 4 offset += 4
// 32 byte block hash // 32 byte block hash
blockHash := payload[offset:offset+32] blockHash := payload[offset : offset+32]
offset += 32 offset += 32
// 2 byte validator id // 2 byte validator id
leaderId := string(payload[offset:offset+2]) leaderId := string(payload[offset : offset+2])
offset += 2 offset += 2
// n byte of block header // n byte of block header
n := len(payload) - offset - 4 - 64 // the numbers means 4 byte payload and 64 signature n := len(payload) - offset - 4 - 64 // the numbers means 4 byte payload and 64 signature
blockHeader := payload[offset:offset+n] blockHeader := payload[offset : offset+n]
offset += n offset += n
// 4 byte of payload size (block header) // 4 byte of payload size (block header)
blockHeaderSize := payload[offset:offset+4] blockHeaderSize := payload[offset : offset+4]
offset += 4 offset += 4
// 64 byte of signature on previous data // 64 byte of signature on previous data
signature := payload[offset:offset+64] signature := payload[offset : offset+64]
offset += 64 offset += 64
//#### END: Read payload data //#### END: Read payload data
@ -122,31 +122,31 @@ func (consensus *Consensus) processChallengeMessage(payload []byte) {
//#### Read payload data //#### Read payload data
offset := 0 offset := 0
// 4 byte consensus id // 4 byte consensus id
consensusId := binary.BigEndian.Uint32(payload[offset:offset+4]) consensusId := binary.BigEndian.Uint32(payload[offset : offset+4])
offset += 4 offset += 4
// 32 byte block hash // 32 byte block hash
blockHash := payload[offset:offset+32] blockHash := payload[offset : offset+32]
offset += 32 offset += 32
// 2 byte leader id // 2 byte leader id
leaderId := string(payload[offset:offset+2]) leaderId := string(payload[offset : offset+2])
offset += 2 offset += 2
// 33 byte of aggregated commit // 33 byte of aggregated commit
aggreCommit := payload[offset:offset+33] aggreCommit := payload[offset : offset+33]
offset += 33 offset += 33
// 33 byte of aggregated key // 33 byte of aggregated key
aggreKey := payload[offset:offset+33] aggreKey := payload[offset : offset+33]
offset += 33 offset += 33
// 32 byte of aggregated key // 32 byte of aggregated key
challenge := payload[offset:offset+32] challenge := payload[offset : offset+32]
offset += 32 offset += 32
// 64 byte of signature on previous data // 64 byte of signature on previous data
signature := payload[offset:offset+64] signature := payload[offset : offset+64]
offset += 64 offset += 64
//#### END: Read payload data //#### END: Read payload data

Loading…
Cancel
Save