update master

pull/4377/head
frozen 2 years ago committed by Casey Gardiner
parent f67d90be9d
commit 61236819bc
  1. 2
      api/service/explorer/service.go
  2. 9
      consensus/consensus_v2.go
  3. 2
      consensus/view_change.go
  4. 1
      node/node_newblock.go

@ -223,6 +223,8 @@ func (s *Service) GetBlocks(w http.ResponseWriter, r *http.Request) {
for i := cur; i > 0; i-- {
block := s.blockchain.GetBlockByNumber(i)
leaderPubKey, _ := chain.GetLeaderPubKeyFromCoinbase(s.backend.Blockchain(), block.Header())
w.Write([]byte(fmt.Sprintf("%s ", leaderPubKey.Bytes.Hex())))
w.Write([]byte(fmt.Sprintf("#%d ", i)))
w.Write([]byte(fmt.Sprintf("v%s ", block.Header().ViewID().String())))
w.Write([]byte(fmt.Sprintf("e%d ", block.Header().Epoch().Uint64())))

@ -708,21 +708,18 @@ func (consensus *Consensus) SetupForNewConsensus(blk *types.Block, committedMsg
pps := consensus.Decider.Participants()
idx := (int(diff) / 3) % len(pps)
consensus.pubKeyLock.Lock()
fmt.Println("(int(diff)/3)%len(pps) == ", idx)
//fmt.Println("(int(diff)/3)%len(pps) == ", idx)
consensus.LeaderPubKey = &pps[idx]
fmt.Printf("SetupForNewConsensus :%d idx: %d future v%d new: %s prev: %s %v\n", utils.GetPort(), idx, curBlockViewID, consensus.LeaderPubKey.Bytes.Hex(), prev.Bytes.Hex(), consensus.isLeader())
//fmt.Printf("SetupForNewConsensus :%d idx: %d future v%d new: %s prev: %s %v\n", utils.GetPort(), idx, curBlockViewID, consensus.LeaderPubKey.Bytes.Hex(), prev.Bytes.Hex(), consensus.isLeader())
consensus.pubKeyLock.Unlock()
if consensus.IsLeader() && !consensus.GetLeaderPubKey().Object.IsEqual(prev.Object) {
// leader changed
go func() {
fmt.Printf("ReadySignal :%d for leader %s\n", utils.GetPort(), consensus.GetLeaderPubKey().Bytes.Hex())
defer fmt.Printf("Defer ReadySignal :%d for leader %s\n", utils.GetPort(), consensus.GetLeaderPubKey().Bytes.Hex())
consensus.ReadySignal <- SyncProposal
}()
}
} else {
fmt.Printf("SetupForNewConsensus0 :%d future v%d new: %s prev: %s %v\n", utils.GetPort(), curBlockViewID, consensus.LeaderPubKey.Bytes.Hex(), prev.Bytes.Hex(), consensus.isLeader())
fmt.Printf("SetupForNewConsensus0 Before LeaderRotation")
consensus.pubKeyLock.Lock()
consensus.LeaderPubKey = committedMsg.SenderPubkeys[0]
consensus.pubKeyLock.Unlock()

@ -257,7 +257,7 @@ func createTimeout() map[TimeoutType]*utils.Timeout {
// startViewChange start the view change process
func (consensus *Consensus) startViewChange() {
fmt.Printf("Message to send leader111: %d %s \n", utils.GetPort(), consensus.LeaderPubKey.Bytes.Hex())
fmt.Printf("[startViewChange]: %d %s \n", utils.GetPort(), consensus.LeaderPubKey.Bytes.Hex())
if consensus.disableViewChange || consensus.IsBackup() {
return
}

@ -148,7 +148,6 @@ func (node *Node) ProposeNewBlock(commitSigs chan []byte) (*types.Block, error)
if node.Blockchain().Config().IsStaking(header.Epoch()) {
blsPubKeyBytes := leaderKey.Object.GetAddress()
coinbase.SetBytes(blsPubKeyBytes[:])
fmt.Println("coinbase.SetBytes leader: ", leaderKey.Bytes.Hex(), coinbase.Hex())
}
emptyAddr := common.Address{}

Loading…
Cancel
Save