Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tahoe-CHK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
PrivateStorage
Tahoe-CHK
Commits
65feba9b
Commit
65feba9b
authored
Jan 22, 2021
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
Split upload into separate encoding and uploading operations
Still provide a helper that does it all, though - `store`
parent
e6350847
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/Main.hs
+5
-3
5 additions, 3 deletions
app/Main.hs
src/Upload.hs
+41
-15
41 additions, 15 deletions
src/Upload.hs
with
46 additions
and
18 deletions
app/Main.hs
+
5
−
3
View file @
65feba9b
...
@@ -45,7 +45,7 @@ import Upload
...
@@ -45,7 +45,7 @@ import Upload
,
filesystemUploadableRandomConvergence
,
filesystemUploadableRandomConvergence
,
filesystemUploadableWithConvergence
,
filesystemUploadableWithConvergence
,
filesystemStorageServer
,
filesystemStorageServer
,
upload
,
store
,
prettyFormatSharemap
,
prettyFormatSharemap
)
)
...
@@ -99,10 +99,12 @@ main = do
...
@@ -99,10 +99,12 @@ main = do
Right
bytesSecret
->
Right
bytesSecret
->
filesystemUploadableWithConvergence
bytesSecret
path
params
filesystemUploadableWithConvergence
bytesSecret
path
params
servers
>>=
upload
uploadable
>>=
report_upload
servers
<-
getServers
result
<-
store
servers
uploadable
report_upload
result
where
where
s
ervers
=
mapM
filesystemStorageServer
getS
ervers
=
mapM
filesystemStorageServer
[
"storage001"
[
"storage001"
,
"storage002"
,
"storage002"
,
"storage003"
,
"storage003"
...
...
This diff is collapsed.
Click to expand it.
src/Upload.hs
+
41
−
15
View file @
65feba9b
...
@@ -9,6 +9,7 @@ module Upload
...
@@ -9,6 +9,7 @@ module Upload
,
filesystemStorageServer
,
filesystemStorageServer
,
getConvergentKey
,
getConvergentKey
,
upload
,
upload
,
store
,
prettyFormatSharemap
,
prettyFormatSharemap
,
adjustSegmentSize
,
adjustSegmentSize
...
@@ -204,23 +205,48 @@ uploadImmutableShares storageIndex uploads = do
...
@@ -204,23 +205,48 @@ uploadImmutableShares storageIndex uploads = do
uploadOneChunk
offset
storageIndex
(
shareNum
,
server
,
shareData
)
=
uploadOneChunk
offset
storageIndex
(
shareNum
,
server
,
shareData
)
=
storageServerWrite
server
storageIndex
shareNum
offset
shareData
storageServerWrite
server
storageIndex
shareNum
offset
shareData
-- Given some cleartext, some encoding parameters, and some servers: encrypt,
-- encode, and upload some shares that can later be used to reconstruct the
-- | Encrypt and encode some application data to some ZFEC shares and upload
-- cleartext.
-- them to some servers.
store
::
-- | The servers to consider using.
[
StorageServer
]
->
-- | The application data to operate on.
Uploadable
->
-- | The result of the attempt.
IO
UploadResult
store
servers
uploadable
@
(
Uploadable
key
_
params
_
)
=
encryptAndEncode
uploadable
>>=
upload
servers
key
params
-- | Given some cleartext and some encoding parameters: encrypt and encode some
-- shares that can later be used to reconstruct the cleartext.
encryptAndEncode
::
-- | The application data to encrypt and encode.
Uploadable
->
-- | An action to get an action that can be repeatedly evaluated to get
-- share data. As long as there is more share data, it evaluates to Left.
-- When shares are done, it evaluates to Right.
IO
(
IO
(
Either
[
B
.
ByteString
]
(
AESKey128
->
Capability
)))
encryptAndEncode
(
Uploadable
key
size
params
read
)
=
chkEncrypt
key
read
>>=
makeChkEncoder
params
size
-- | Given some cleartext, some encoding parameters, and some servers:
-- encrypt, encode, and upload some shares that can later be used to
-- reconstruct the cleartext.
--
--
-- This replaces allmydata.immutable.upload.Uploader.upload.
-- This replaces allmydata.immutable.upload.Uploader.upload.
upload
::
Uploadable
->
[
StorageServer
]
->
IO
UploadResult
upload
::
upload
Uploadable
-- | The servers to consider uploading shares to.
{
uploadableKey
=
key
[
StorageServer
]
->
,
uploadableSize
=
size
-- | The encryption key (to derive the storage index).
,
uploadableParameters
=
params
AESKey128
->
,
uploadableReadCleartext
=
readCleartext
-- | The encoding parameters (XXX only for happy, right?)
}
servers
=
do
Parameters
->
-- | An action to repeatedly evaluate to get share data or the cap.
-- Prepare the share data
(
IO
(
Either
[
B
.
ByteString
]
(
AESKey128
->
Capability
)))
->
readCiphertext
<-
chkEncrypt
key
readCleartext
-- | Describe the outcome of the upload.
streams
<-
makeChkEncoder
params
size
readCiphertex
t
IO
UploadResul
t
upload
servers
key
params
streams
=
do
-- Decide where to put it
-- Decide where to put it
existingShares
<-
locateAllShareholders
storageIndex
servers
existingShares
<-
locateAllShareholders
storageIndex
servers
let
targets
=
targetServers
params
existingShares
let
targets
=
targetServers
params
existingShares
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment