Merge branch 'master' of github.com:harmony-one/harmony into version_block

pull/1546/head
Eugene Kim 5 years ago
commit 053a0af57d
  1. 4
      api/service/syncing/downloader/client.go
  2. 1
      block/factory/factory.go
  3. 3
      consensus/consensus_service.go
  4. 3
      consensus/consensus_v2.go
  5. 7
      node/node_syncing.go

@ -89,7 +89,7 @@ func (client *Client) Register(hash []byte, ip, port string) *pb.DownloaderRespo
}
// PushNewBlock will send the lastest verified block to registered nodes
func (client *Client) PushNewBlock(selfPeerHash [20]byte, blockHash []byte, timeout bool) *pb.DownloaderResponse {
func (client *Client) PushNewBlock(selfPeerHash [20]byte, blockHash []byte, timeout bool) (*pb.DownloaderResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
@ -107,7 +107,7 @@ func (client *Client) PushNewBlock(selfPeerHash [20]byte, blockHash []byte, time
if err != nil {
utils.Logger().Error().Err(err).Str("target", client.conn.Target()).Msg("[SYNC] unable to send new block to unsync node")
}
return response
return response, err
}
// GetBlockChainHeight gets the blockheight from peer

@ -33,6 +33,7 @@ func (f *factory) NewHeader(epoch *big.Int) *block.Header {
default:
impl = v0.NewHeader()
}
impl.SetEpoch(epoch)
return &block.Header{impl}
}

@ -412,13 +412,12 @@ func (consensus *Consensus) reportMetrics(block types.Block) {
timeElapsed := endTime.Sub(startTime)
numOfTxs := len(block.Transactions())
tps := float64(numOfTxs) / timeElapsed.Seconds()
utils.Logger().Info().
consensus.getLogger().Info().
Int("numOfTXs", numOfTxs).
Time("startTime", startTime).
Time("endTime", endTime).
Dur("timeElapsed", endTime.Sub(startTime)).
Float64("TPS", tps).
Interface("consensus", consensus).
Msg("TPS Report")
// Post metrics

@ -33,7 +33,7 @@ func (consensus *Consensus) handleMessageUpdate(payload []byte) {
msg := &msg_pb.Message{}
err := protobuf.Unmarshal(payload, msg)
if err != nil {
utils.Logger().Error().Err(err).Interface("consensus", consensus).Msg("Failed to unmarshal message payload.")
consensus.getLogger().Error().Err(err).Msg("Failed to unmarshal message payload.")
return
}
@ -1161,7 +1161,6 @@ func (consensus *Consensus) Start(blockChannel chan *types.Block, stopChan chan
consensus.getLogger().Debug().
Int("numTxs", len(newBlock.Transactions())).
Interface("consensus", consensus).
Time("startTime", startTime).
Int("publicKeys", len(consensus.PublicKeys)).
Msg("[ConsensusMainLoop] STARTING CONSENSUS")

@ -296,7 +296,12 @@ func (node *Node) SendNewBlockToUnsync() {
delete(node.peerRegistrationRecord, peerID)
continue
}
response := config.client.PushNewBlock(node.GetSyncID(), blockHash, false)
response, err := config.client.PushNewBlock(node.GetSyncID(), blockHash, false)
// close the connection if cannot push new block to unsync node
if err != nil {
node.peerRegistrationRecord[peerID].client.Close()
delete(node.peerRegistrationRecord, peerID)
}
if response != nil && response.Type == downloader_pb.DownloaderResponse_INSYNC {
node.peerRegistrationRecord[peerID].client.Close()
delete(node.peerRegistrationRecord, peerID)

Loading…
Cancel
Save