Skip to content

Commit c6bbd08

Browse files
committed
cc: support stream version
1 parent 2f842d7 commit c6bbd08

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

controller/connect_controller.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ func nextContract(
298298
if createContract.ForceStream != nil {
299299
forceStream = *createContract.ForceStream
300300
}
301+
streamVersion := 0
302+
if createContract.StreamVersion != nil {
303+
streamVersion = int(*createContract.StreamVersion)
304+
}
301305
// new contract
302306
return newContract(
303307
ctx,
@@ -309,6 +313,7 @@ func nextContract(
309313
model.ByteCount(createContract.TransferByteCount),
310314
provideMode,
311315
forceStream,
316+
streamVersion,
312317
)
313318
}
314319

@@ -321,6 +326,7 @@ func newContract(
321326
transferByteCount model.ByteCount,
322327
provideMode model.ProvideMode,
323328
forceStream bool,
329+
streamVersion int,
324330
) (contractId server.Id, contractTransferByteCount model.ByteCount, priority model.Priority, streamId *server.Id, returnErr error) {
325331
sourceNetworkId, err := model.FindClientNetwork(ctx, sourceId)
326332
if err != nil {
@@ -371,10 +377,15 @@ func newContract(
371377
contractId = escrow.ContractId
372378
priority = escrow.Priority
373379

374-
companionContractId := *escrow.CompanionContractId
375-
streamId_, _, ok := model.GetStream(ctx, companionContractId)
376-
if ok {
377-
streamId = &streamId_
380+
switch streamVersion {
381+
case 0:
382+
// companion stream is not supported
383+
default:
384+
companionContractId := *escrow.CompanionContractId
385+
streamId_, _, ok := model.GetStream(ctx, companionContractId)
386+
if ok {
387+
streamId = &streamId_
388+
}
378389
}
379390
} else {
380391
// TODO store the intermediary ids on the contract so they can be rewarded in the payout

0 commit comments

Comments
 (0)