lotus/chain/blockmsg.go

37 lines
630 B
Go
Raw Normal View History

2019-08-22 19:30:57 +00:00
package chain
import (
"bytes"
"github.com/ipfs/go-cid"
"github.com/filecoin-project/go-lotus/chain/types"
)
type BlockMsg struct {
Header *types.BlockHeader
BlsMessages []cid.Cid
SecpkMessages []cid.Cid
}
func DecodeBlockMsg(b []byte) (*BlockMsg, error) {
var bm BlockMsg
if err := bm.UnmarshalCBOR(bytes.NewReader(b)); err != nil {
return nil, err
}
return &bm, nil
}
func (bm *BlockMsg) Cid() cid.Cid {
return bm.Header.Cid()
}
func (bm *BlockMsg) Serialize() ([]byte, error) {
buf := new(bytes.Buffer)
if err := bm.MarshalCBOR(buf); err != nil {
return nil, err
}
return buf.Bytes(), nil
}