Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nullable TransferRequest1_1.RestartChannel #315

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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