Fix insertChain return

pull/1348/head
Rongjian Lan 5 years ago
parent 1307f48090
commit 747cecfe86
  1. 2
      api/proto/node/node.go
  2. 4
      core/blockchain.go

@ -165,7 +165,7 @@ func ConstructBlocksSyncMessage(blocks []*types.Block) []byte {
return byteBuffer.Bytes()
}
// ConstructCrossLinkHeadersMessage constructs cross link header message to send blocks to beacon chain
// ConstructCrossLinkHeadersMessage constructs cross link header message to send to beacon chain
func ConstructCrossLinkHeadersMessage(headers []*types.Header) []byte {
byteBuffer := bytes.NewBuffer([]byte{byte(proto.Node)})
byteBuffer.WriteByte(byte(Block))

@ -1119,13 +1119,15 @@ func (bc *BlockChain) InsertChain(chain types.Blocks) (int, error) {
err = bc.WriteShardStateBytes(epoch, header.ShardState)
if err != nil {
header.Logger(utils.Logger()).Warn().Err(err).Msg("cannot store shard state")
return n, err
}
}
if len(header.CrossLinks) > 0 {
crossLinks := &types.CrossLinks{}
err := rlp.DecodeBytes(header.CrossLinks, crossLinks)
err = rlp.DecodeBytes(header.CrossLinks, crossLinks)
if err != nil {
header.Logger(utils.Logger()).Warn().Err(err).Msg("[insertChain] cannot parse cross links")
return n, err
}
for _, crossLink := range *crossLinks {
bc.WriteCrossLinks(types.CrossLinks{crossLink}, false)

Loading…
Cancel
Save