|
|
|
@ -82,6 +82,7 @@ func (consensus *Consensus) UpdatePublicKeys(pubKeys, allowlist []bls_cosi.Publi |
|
|
|
|
|
|
|
|
|
func (consensus *Consensus) updatePublicKeys(pubKeys, allowlist []bls_cosi.PublicKeyWrapper) int64 { |
|
|
|
|
consensus.Decider.UpdateParticipants(pubKeys, allowlist) |
|
|
|
|
consensus.pubKeyLock.Unlock() |
|
|
|
|
consensus.getLogger().Info().Msg("My Committee updated") |
|
|
|
|
for i := range pubKeys { |
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
@ -89,15 +90,22 @@ func (consensus *Consensus) updatePublicKeys(pubKeys, allowlist []bls_cosi.Publi |
|
|
|
|
Str("BLSPubKey", pubKeys[i].Bytes.Hex()). |
|
|
|
|
Msg("Member") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
allKeys := consensus.Decider.Participants() |
|
|
|
|
if len(allKeys) != 0 { |
|
|
|
|
consensus.LeaderPubKey = &allKeys[0] |
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
Str("info", consensus.LeaderPubKey.Bytes.Hex()).Msg("My Leader") |
|
|
|
|
if consensus.Blockchain.Config().IsLeaderRotation(consensus.GetCurEpoch()) { |
|
|
|
|
consensus.updateLeader() |
|
|
|
|
} else { |
|
|
|
|
consensus.getLogger().Error(). |
|
|
|
|
Msg("[UpdatePublicKeys] Participants is empty") |
|
|
|
|
consensus.pubKeyLock.Lock() |
|
|
|
|
allKeys := consensus.Decider.Participants() |
|
|
|
|
consensus.pubKeyLock.Unlock() |
|
|
|
|
if len(allKeys) != 0 { |
|
|
|
|
consensus.pubKeyLock.Lock() |
|
|
|
|
consensus.LeaderPubKey = &allKeys[0] |
|
|
|
|
consensus.pubKeyLock.Unlock() |
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
Str("info", consensus.LeaderPubKey.Bytes.Hex()).Msg("My Leader") |
|
|
|
|
} else { |
|
|
|
|
consensus.getLogger().Error(). |
|
|
|
|
Msg("[UpdatePublicKeys] Participants is empty") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// reset states after update public keys
|
|
|
|
|
// TODO: incorporate bitmaps in the decider, so their state can't be inconsistent.
|
|
|
|
@ -658,3 +666,13 @@ func (consensus *Consensus) getLogger() *zerolog.Logger { |
|
|
|
|
Logger() |
|
|
|
|
return &logger |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdatePublicKeyDefault(consensus *Consensus) { |
|
|
|
|
if allKeys := consensus.Decider.Participants(); len(allKeys) > 0 { |
|
|
|
|
consensus.LeaderPubKey = &allKeys[0] |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func UpdatePublicKeyRotate(consensus *Consensus) { |
|
|
|
|
//consensus
|
|
|
|
|
} |
|
|
|
|