|
|
@ -3,6 +3,7 @@ package consensus |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
"encoding/hex" |
|
|
|
"encoding/hex" |
|
|
|
|
|
|
|
"sync" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
@ -58,8 +59,12 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (consensus *Consensus) prepare() { |
|
|
|
func (consensus *Consensus) prepare() { |
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
|
|
|
|
wg.Add(len(consensus.PubKey.PublicKey)) |
|
|
|
groupID := []nodeconfig.GroupID{nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID))} |
|
|
|
groupID := []nodeconfig.GroupID{nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID))} |
|
|
|
for i, key := range consensus.PubKey.PublicKey { |
|
|
|
for i, key := range consensus.PubKey.PublicKey { |
|
|
|
|
|
|
|
go func(i int) { |
|
|
|
|
|
|
|
defer wg.Done() |
|
|
|
networkMessage, err := consensus.construct(msg_pb.MessageType_PREPARE, nil, key, consensus.priKey.PrivateKey[i]) |
|
|
|
networkMessage, err := consensus.construct(msg_pb.MessageType_PREPARE, nil, key, consensus.priKey.PrivateKey[i]) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
consensus.getLogger().Err(err). |
|
|
|
consensus.getLogger().Err(err). |
|
|
@ -81,7 +86,9 @@ func (consensus *Consensus) prepare() { |
|
|
|
Msg("[OnAnnounce] Sent Prepare Message!!") |
|
|
|
Msg("[OnAnnounce] Sent Prepare Message!!") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}(i) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
wg.Wait() |
|
|
|
consensus.getLogger().Debug(). |
|
|
|
consensus.getLogger().Debug(). |
|
|
|
Str("From", consensus.phase.String()). |
|
|
|
Str("From", consensus.phase.String()). |
|
|
|
Str("To", FBFTPrepare.String()). |
|
|
|
Str("To", FBFTPrepare.String()). |
|
|
@ -207,7 +214,11 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { |
|
|
|
groupID := []nodeconfig.GroupID{ |
|
|
|
groupID := []nodeconfig.GroupID{ |
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), |
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var wg sync.WaitGroup |
|
|
|
|
|
|
|
wg.Add(len(consensus.PubKey.PublicKey)) |
|
|
|
for i, key := range consensus.PubKey.PublicKey { |
|
|
|
for i, key := range consensus.PubKey.PublicKey { |
|
|
|
|
|
|
|
go func(i int) { |
|
|
|
|
|
|
|
defer wg.Done() |
|
|
|
networkMessage, _ := consensus.construct( |
|
|
|
networkMessage, _ := consensus.construct( |
|
|
|
msg_pb.MessageType_COMMIT, |
|
|
|
msg_pb.MessageType_COMMIT, |
|
|
|
commitPayload, |
|
|
|
commitPayload, |
|
|
@ -227,7 +238,9 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { |
|
|
|
Msg("[OnPrepared] Sent Commit Message!!") |
|
|
|
Msg("[OnPrepared] Sent Commit Message!!") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}(i) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
wg.Wait() |
|
|
|
consensus.getLogger().Debug(). |
|
|
|
consensus.getLogger().Debug(). |
|
|
|
Str("From", consensus.phase.String()). |
|
|
|
Str("From", consensus.phase.String()). |
|
|
|
Str("To", FBFTCommit.String()). |
|
|
|
Str("To", FBFTCommit.String()). |
|
|
|