@@ -88,35 +88,52 @@ func NewMsgAwaitReply() *MsgAwaitReply {
8888
8989type MsgRollForwardNtC struct {
9090 protocol.MessageBase
91- WrappedData []byte
92- Tip Tip
91+ WrappedBlock cbor.Tag
92+ Tip Tip
93+ blockType uint
94+ blockCbor []byte
9395}
9496
95- func NewMsgRollForwardNtC (wrappedData []byte , tip Tip ) * MsgRollForwardNtC {
97+ func NewMsgRollForwardNtC (blockType uint , blockCbor []byte , tip Tip ) * MsgRollForwardNtC {
9698 m := & MsgRollForwardNtC {
9799 MessageBase : protocol.MessageBase {
98100 MessageType : MESSAGE_TYPE_ROLL_FORWARD ,
99101 },
100- WrappedData : wrappedData ,
101- Tip : tip ,
102+ Tip : tip ,
103+ }
104+ wb := NewWrappedBlock (blockType , blockCbor )
105+ content , err := cbor .Marshal (wb )
106+ // TODO: figure out better way to handle error
107+ if err != nil {
108+ return nil
102109 }
110+ m .WrappedBlock = cbor.Tag {Number : 24 , Content : content }
103111 return m
104112}
105113
114+ func (m * MsgRollForwardNtC ) BlockType () uint {
115+ return m .blockType
116+ }
117+
118+ func (m * MsgRollForwardNtC ) BlockCbor () []byte {
119+ return m .blockCbor
120+ }
121+
106122type MsgRollForwardNtN struct {
107123 protocol.MessageBase
108124 WrappedHeader WrappedHeader
109125 Tip Tip
110126}
111127
112- func NewMsgRollForwardNtN (wrappedHeader WrappedHeader , tip Tip ) * MsgRollForwardNtN {
128+ func NewMsgRollForwardNtN (era uint , byronType uint , blockCbor [] byte , tip Tip ) * MsgRollForwardNtN {
113129 m := & MsgRollForwardNtN {
114130 MessageBase : protocol.MessageBase {
115131 MessageType : MESSAGE_TYPE_ROLL_FORWARD ,
116132 },
117- WrappedHeader : wrappedHeader ,
118- Tip : tip ,
133+ Tip : tip ,
119134 }
135+ wrappedHeader := NewWrappedHeader (era , byronType , blockCbor )
136+ m .WrappedHeader = * wrappedHeader
120137 return m
121138}
122139
@@ -139,10 +156,10 @@ func NewMsgRollBackward(point Point, tip Tip) *MsgRollBackward {
139156
140157type MsgFindIntersect struct {
141158 protocol.MessageBase
142- Points []interface {}
159+ Points []Point
143160}
144161
145- func NewMsgFindIntersect (points []interface {} ) * MsgFindIntersect {
162+ func NewMsgFindIntersect (points []Point ) * MsgFindIntersect {
146163 m := & MsgFindIntersect {
147164 MessageBase : protocol.MessageBase {
148165 MessageType : MESSAGE_TYPE_FIND_INTERSECT ,
@@ -205,6 +222,8 @@ type Tip struct {
205222}
206223
207224type Point struct {
225+ // Tells the CBOR decoder to convert to/from a struct and a CBOR array
226+ _ struct {} `cbor:",toarray"`
208227 Slot uint64
209228 Hash []byte
210229}
@@ -223,28 +242,13 @@ func (p *Point) UnmarshalCBOR(data []byte) error {
223242 return nil
224243}
225244
226- type WrappedBlock struct {
227- // Tells the CBOR decoder to convert to/from a struct and a CBOR array
228- _ struct {} `cbor:",toarray"`
229- Type uint
230- RawBlock cbor.RawMessage
231- }
232-
233- type WrappedHeader struct {
234- // Tells the CBOR decoder to convert to/from a struct and a CBOR array
235- _ struct {} `cbor:",toarray"`
236- Type uint
237- RawData cbor.RawMessage
238- }
239-
240- type WrappedHeaderByron struct {
241- // Tells the CBOR decoder to convert to/from a struct and a CBOR array
242- _ struct {} `cbor:",toarray"`
243- Unknown struct {
244- // Tells the CBOR decoder to convert to/from a struct and a CBOR array
245- _ struct {} `cbor:",toarray"`
246- Type uint
247- Unknown uint64
248- }
249- RawHeader []byte
245+ func (p * Point ) MarshalCBOR () ([]byte , error ) {
246+ var data []interface {}
247+ if p .Slot == 0 && p .Hash == nil {
248+ // Return an empty list if values are zero
249+ data = make ([]interface {}, 0 )
250+ } else {
251+ data = []interface {}{p .Slot , p .Hash }
252+ }
253+ return utils .CborEncode (data )
250254}
0 commit comments