From d49dafa85ec5c1219df6821d301e03bc091afc76 Mon Sep 17 00:00:00 2001 From: chao Date: Fri, 1 Nov 2019 20:12:38 -0700 Subject: [PATCH] debug block encode/decode --- consensus/consensus_v2.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 58c314b3b..6aa8e5a09 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -95,12 +95,17 @@ func (consensus *Consensus) announce(block *types.Block) { utils.Logger().Debug().Msg("[Announce] Failed encoding block") return } + utils.Logger().Debug().Msgf("haha1, before:%v ", len(block.StakingTransactions())) encodedBlockHeader, err := rlp.EncodeToBytes(block.Header()) if err != nil { utils.Logger().Debug().Msg("[Announce] Failed encoding block header") 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.blockHeader = encodedBlockHeader msgToSend := consensus.constructAnnounceMessage() @@ -407,10 +412,12 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) { msg := &msg_pb.Message{} _ = protobuf.Unmarshal(msgPayload, msg) FBFTMsg, err := ParseFBFTMessage(msg) + if err != nil { utils.Logger().Warn().Err(err).Msg("[OnPrepare] Unable to parse pbft message") return } + consensus.FBFTLog.AddMessage(FBFTMsg) // Leader add commit phase signature blockNumHash := make([]byte, 8)