|
|
@ -4,11 +4,11 @@ import ( |
|
|
|
"log" |
|
|
|
"log" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
|
|
|
|
|
|
|
|
|
"harmony-benchmark/p2p" |
|
|
|
|
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
"encoding/binary" |
|
|
|
"encoding/binary" |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"harmony-benchmark/p2p" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var mutex = &sync.Mutex{} |
|
|
|
var mutex = &sync.Mutex{} |
|
|
@ -38,6 +38,8 @@ func (consensus *Consensus) ProcessMessageLeader(message []byte) { |
|
|
|
consensus.processResponseMessage(payload) |
|
|
|
consensus.processResponseMessage(payload) |
|
|
|
case START_CONSENSUS: |
|
|
|
case START_CONSENSUS: |
|
|
|
consensus.processStartConsensusMessage(msg) |
|
|
|
consensus.processStartConsensusMessage(msg) |
|
|
|
|
|
|
|
case STOP_CONSENSUS: |
|
|
|
|
|
|
|
consensus.stopConsensusMessage(msg) |
|
|
|
default: |
|
|
|
default: |
|
|
|
log.Println("Unexpected message type: %s", msgType) |
|
|
|
log.Println("Unexpected message type: %s", msgType) |
|
|
|
} |
|
|
|
} |
|
|
@ -119,23 +121,23 @@ func (consensus *Consensus) processCommitMessage(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
|
|
|
|
validatorId := string(payload[offset:offset+2]) |
|
|
|
validatorId := string(payload[offset : offset+2]) |
|
|
|
offset += 2 |
|
|
|
offset += 2 |
|
|
|
|
|
|
|
|
|
|
|
// 33 byte commit
|
|
|
|
// 33 byte commit
|
|
|
|
commit := payload[offset:offset+33] |
|
|
|
commit := payload[offset : offset+33] |
|
|
|
offset += 33 |
|
|
|
offset += 33 |
|
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
|
|
|
@ -225,23 +227,23 @@ func (consensus *Consensus) processResponseMessage(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
|
|
|
|
validatorId := string(payload[offset:offset+2]) |
|
|
|
validatorId := string(payload[offset : offset+2]) |
|
|
|
offset += 2 |
|
|
|
offset += 2 |
|
|
|
|
|
|
|
|
|
|
|
// 32 byte response
|
|
|
|
// 32 byte response
|
|
|
|
response := payload[offset:offset+32] |
|
|
|
response := 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
|
|
|
|
|
|
|
|
|
|
|
|