Skip to content

Commit

Permalink
nullable TransferRequest1_1.RestartChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
turuslan committed Mar 28, 2022
1 parent 48303da commit 4a1455d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion message/message1_1/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func NewRequest(id datatransfer.TransferID, isRestart bool, isPull bool, vtype d
func RestartExistingChannelRequest(channelId datatransfer.ChannelID) datatransfer.Request {

return &TransferRequest1_1{Type: uint64(types.RestartExistingChannelRequestMessage),
RestartChannel: channelId}
RestartChannel: &channelId}
}

// CancelRequest request generates a request to cancel an in progress request
Expand Down
7 changes: 5 additions & 2 deletions message/message1_1/transfer_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type TransferRequest1_1 struct {
VTyp datatransfer.TypeIdentifier
XferID uint64

RestartChannel datatransfer.ChannelID
RestartChannel *datatransfer.ChannelID
}

func (trq *TransferRequest1_1) MessageForProtocol(targetProtocol protocol.ID) (datatransfer.Message, error) {
Expand Down Expand Up @@ -62,7 +62,10 @@ func (trq *TransferRequest1_1) RestartChannelId() (datatransfer.ChannelID, error
if !trq.IsRestartExistingChannelRequest() {
return datatransfer.ChannelID{}, xerrors.New("not a restart request")
}
return trq.RestartChannel, nil
if trq.RestartChannel == nil {
return datatransfer.ChannelID{}, xerrors.New("TransferRequest1_1.RestartChannel = nil")
}
return *trq.RestartChannel, nil
}

func (trq *TransferRequest1_1) IsNew() bool {
Expand Down
14 changes: 12 additions & 2 deletions message/message1_1/transfer_request_cbor_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion message/message1_1prime/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewRequest(id datatransfer.TransferID, isRestart bool, isPull bool, vtype d
func RestartExistingChannelRequest(channelId datatransfer.ChannelID) datatransfer.Request {
return &TransferRequest1_1{
MessageType: uint64(types.RestartExistingChannelRequestMessage),
RestartChannel: channelId,
RestartChannel: &channelId,
}
}

Expand Down
2 changes: 1 addition & 1 deletion message/message1_1prime/schema.ipldsch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type TransferRequest struct {
VoucherPtr nullable Any (rename "Vouch")
VoucherTypeIdentifier TypeIdentifier (rename "VTyp")
TransferId Int (rename "XferID")
RestartChannel ChannelID
RestartChannel nullable ChannelID
}

type TransferResponse struct {
Expand Down
7 changes: 5 additions & 2 deletions message/message1_1prime/transfer_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type TransferRequest1_1 struct {
VoucherPtr *datamodel.Node
VoucherTypeIdentifier datatransfer.TypeIdentifier
TransferId uint64
RestartChannel datatransfer.ChannelID
RestartChannel *datatransfer.ChannelID
}

func (trq *TransferRequest1_1) MessageForProtocol(targetProtocol protocol.ID) (datatransfer.Message, error) {
Expand Down Expand Up @@ -56,7 +56,10 @@ func (trq *TransferRequest1_1) RestartChannelId() (datatransfer.ChannelID, error
if !trq.IsRestartExistingChannelRequest() {
return datatransfer.ChannelID{}, xerrors.New("not a restart request")
}
return trq.RestartChannel, nil
if trq.RestartChannel == nil {
return datatransfer.ChannelID{}, xerrors.New("TransferRequest1_1.RestartChannel = nil")
}
return *trq.RestartChannel, nil
}

func (trq *TransferRequest1_1) IsNew() bool {
Expand Down

0 comments on commit 4a1455d

Please sign in to comment.