-
Notifications
You must be signed in to change notification settings - Fork 6
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
Feature/stream start, finish #111
Open
cyrillicw
wants to merge
7
commits into
feature/ReplicatorOffboarding
Choose a base branch
from
feature/stream-start
base: feature/ReplicatorOffboarding
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6e8cd12
Stream Start
cyrillicw e85efb1
Stream Start Buffer
cyrillicw 8debd26
Stream Start DTO repair
cyrillicw ceed75f
ActiveDataModification DTO repair
cyrillicw 2d4e37f
remove hex decoding in stream dto
cyrillicw 892960e
Stream Finish
cyrillicw 4763c42
Stream Payment
cyrillicw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,4 +170,5 @@ const ( | |
ByteSize VarSize = 1 | ||
ShortSize VarSize = 2 | ||
IntSize VarSize = 4 | ||
LongSize VarSize = 8 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright 2021 ProximaX Limited. All rights reserved. | ||
// Use of this source code is governed by the Apache 2.0 | ||
// license that can be found in the LICENSE file. | ||
|
||
package sdk | ||
|
||
type StreamingV2Service service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2021 ProximaX Limited. All rights reserved. | ||
// Use of this source code is governed by the Apache 2.0 | ||
// license that can be found in the LICENSE file. | ||
|
||
package sdk | ||
|
||
type StreamStartTransaction struct { | ||
AbstractTransaction | ||
DriveKey string | ||
ExpectedUploadSize StorageSize | ||
Folder string | ||
FeedbackFeeAmount Amount | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2021 ProximaX Limited. All rights reserved. | ||
// Use of this source code is governed by the Apache 2.0 | ||
// license that can be found in the LICENSE file. | ||
|
||
package sdk | ||
|
||
func streamStartTransactionSchema() *schema { | ||
return &schema{ | ||
[]schemaAttribute{ | ||
newScalarAttribute("size", IntSize), | ||
newArrayAttribute("signature", ByteSize), | ||
newArrayAttribute("signer", ByteSize), | ||
newScalarAttribute("version", IntSize), | ||
newScalarAttribute("type", ShortSize), | ||
newArrayAttribute("maxFee", IntSize), | ||
newArrayAttribute("deadline", IntSize), | ||
newArrayAttribute("driveKey", ByteSize), | ||
newScalarAttribute("expectedUploadSize", LongSize), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. look at other newArrayAttribute("expectedUploadSize", IntSize) |
||
newScalarAttribute("folderSize", ShortSize), | ||
newScalarAttribute("feedbackFeeAmount", LongSize), | ||
newArrayAttribute("folder", ByteSize), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
// Copyright 2021 ProximaX Limited. All rights reserved. | ||
// Use of this source code is governed by the Apache 2.0 | ||
// license that can be found in the LICENSE file. | ||
|
||
package sdk | ||
|
||
import ( | ||
"encoding/hex" | ||
flatbuffers "github.com/google/flatbuffers/go" | ||
"github.com/proximax-storage/go-xpx-chain-sdk/transactions" | ||
) | ||
|
||
func NewStreamStartTransaction( | ||
deadline *Deadline, | ||
driveKey string, | ||
expectedUploadSize StorageSize, | ||
folder string, | ||
feedbackFeeAmount Amount, | ||
networkType NetworkType, | ||
) (*StreamStartTransaction, error) { | ||
|
||
tx := StreamStartTransaction{ | ||
AbstractTransaction: AbstractTransaction{ | ||
Deadline: deadline, | ||
Version: StreamStartVersion, | ||
Type: StreamStart, | ||
NetworkType: networkType, | ||
}, | ||
DriveKey: driveKey, | ||
ExpectedUploadSize: expectedUploadSize, | ||
Folder: folder, | ||
FeedbackFeeAmount: feedbackFeeAmount, | ||
} | ||
|
||
return &tx, nil | ||
} | ||
|
||
func (tx *StreamStartTransaction) GetAbstractTransaction() *AbstractTransaction { | ||
return &tx.AbstractTransaction | ||
} | ||
|
||
func (tx *StreamStartTransaction) String() string { | ||
return "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forgotten implementation? |
||
} | ||
|
||
func (tx *StreamStartTransaction) Bytes() ([]byte, error) { | ||
builder := flatbuffers.NewBuilder(0) | ||
|
||
bytes := []byte(tx.Folder) | ||
fp := transactions.TransactionBufferCreateByteVector(builder, bytes) | ||
|
||
v, signatureV, signerV, deadlineV, fV, err := tx.AbstractTransaction.generateVectors(builder) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
driveKeyB, err := hex.DecodeString(tx.DriveKey) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
driveKeyV := transactions.TransactionBufferCreateByteVector(builder, driveKeyB) | ||
|
||
transactions.StreamStartTransactionBufferStart(builder) | ||
transactions.TransactionBufferAddSize(builder, tx.Size()) | ||
tx.AbstractTransaction.buildVectors(builder, v, signatureV, signerV, deadlineV, fV) | ||
|
||
transactions.StreamStartTransactionBufferAddDriveKey(builder, driveKeyV) | ||
transactions.StreamStartTransactionBufferAddExpectedUploadSize(builder, uint64(tx.ExpectedUploadSize)) | ||
transactions.StreamStartTransactionBufferAddFolderSize(builder, uint16(tx.FolderSize())) | ||
|
||
transactions.StreamStartTransactionBufferAddFolder(builder, fp) | ||
|
||
transactions.StreamStartTransactionBufferAddFeedbackFeeAmount(builder, uint64(tx.FeedbackFeeAmount)) | ||
|
||
t := transactions.StreamStartTransactionBufferEnd(builder) | ||
builder.Finish(t) | ||
|
||
return streamStartTransactionSchema().serialize(builder.FinishedBytes()), nil | ||
} | ||
|
||
func (tx *StreamStartTransaction) Size() int { | ||
return StreamStartHeaderSize + tx.FolderSize() | ||
} | ||
|
||
func (tx *StreamStartTransaction) FolderSize() int { | ||
return len(tx.Folder) | ||
} | ||
|
||
type streamStartTransactionDTO struct { | ||
Tx struct { | ||
abstractTransactionDTO | ||
DriveKey string `json:"driveKey"` | ||
ExpectedUploadSize uint64DTO `json:"expectedUploadSize"` | ||
Folder string `json:"folder"` | ||
FeedbackFeeAmount uint64DTO `json:"feedbackFeeAmount"` | ||
} `json:"transaction"` | ||
TDto transactionInfoDTO `json:"meta"` | ||
} | ||
|
||
func (dto *streamStartTransactionDTO) toStruct(*Hash) (Transaction, error) { | ||
info, err := dto.TDto.toStruct() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
atx, err := dto.Tx.abstractTransactionDTO.toStruct(info) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &StreamStartTransaction{ | ||
*atx, | ||
dto.Tx.DriveKey, | ||
dto.Tx.ExpectedUploadSize.toStruct(), | ||
dto.Tx.Folder, | ||
dto.Tx.FeedbackFeeAmount.toStruct(), | ||
}, nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usually, we use an array of
IntSize
foruint64/int64