debug block encode/decode

pull/1795/head
chao 5 years ago
parent 1ee2ab5866
commit d49dafa85e
  1. 7
      consensus/consensus_v2.go

@ -95,12 +95,17 @@ func (consensus *Consensus) announce(block *types.Block) {
utils.Logger().Debug().Msg("[Announce] Failed encoding block") utils.Logger().Debug().Msg("[Announce] Failed encoding block")
return return
} }
utils.Logger().Debug().Msgf("haha1, before:%v ", len(block.StakingTransactions()))
encodedBlockHeader, err := rlp.EncodeToBytes(block.Header()) encodedBlockHeader, err := rlp.EncodeToBytes(block.Header())
if err != nil { if err != nil {
utils.Logger().Debug().Msg("[Announce] Failed encoding block header") utils.Logger().Debug().Msg("[Announce] Failed encoding block header")
return return
} }
var blockObj1 types.Block
err = rlp.DecodeBytes(encodedBlock, &blockObj1)
utils.Logger().Debug().Msgf("haha2, after stks:= %v", len(blockObj1.StakingTransactions()))
consensus.block = encodedBlock consensus.block = encodedBlock
consensus.blockHeader = encodedBlockHeader consensus.blockHeader = encodedBlockHeader
msgToSend := consensus.constructAnnounceMessage() msgToSend := consensus.constructAnnounceMessage()
@ -407,10 +412,12 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
msg := &msg_pb.Message{} msg := &msg_pb.Message{}
_ = protobuf.Unmarshal(msgPayload, msg) _ = protobuf.Unmarshal(msgPayload, msg)
FBFTMsg, err := ParseFBFTMessage(msg) FBFTMsg, err := ParseFBFTMessage(msg)
if err != nil { if err != nil {
utils.Logger().Warn().Err(err).Msg("[OnPrepare] Unable to parse pbft message") utils.Logger().Warn().Err(err).Msg("[OnPrepare] Unable to parse pbft message")
return return
} }
consensus.FBFTLog.AddMessage(FBFTMsg) consensus.FBFTLog.AddMessage(FBFTMsg)
// Leader add commit phase signature // Leader add commit phase signature
blockNumHash := make([]byte, 8) blockNumHash := make([]byte, 8)

Loading…
Cancel
Save