Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gbs-downloader
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
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
gbs-downloader
Commits
24c7db55
Commit
24c7db55
authored
1 year ago
by
Jean-Paul Calderone
Browse files
Options
Downloads
Patches
Plain Diff
minor formatting, haddock improvements
parent
1683964c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Cleanup immutable factoring
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Tahoe/Download.hs
+31
-12
31 additions, 12 deletions
src/Tahoe/Download.hs
src/Tahoe/Download/Internal/Client.hs
+6
-0
6 additions, 0 deletions
src/Tahoe/Download/Internal/Client.hs
src/Tahoe/Download/Internal/Immutable.hs
+4
-0
4 additions, 0 deletions
src/Tahoe/Download/Internal/Immutable.hs
with
41 additions
and
12 deletions
src/Tahoe/Download.hs
+
31
−
12
View file @
24c7db55
...
...
@@ -88,17 +88,19 @@ firstStorageServer servers finder = do
responses
<-
mapM
finder
servers
pure
$
head
$
take
1
$
rights
responses
-- XXX don't do this at home kids, head isn't safe
{-
getShareNumbers :: server -> storageIndex -> IO [ShareNumber]
for mutables, getMutableShareNumbers
getEncodingParameters :: Capability -> StorageServer -> IO (n,k)
it's pure for CHK (immutables), but must be requested from the server for mutables
this returns the FEC encoding values so you know when to stop fetching shares
getStorageIndex :: Capability -> StorageIndex
-}
-- | A capability which confers the ability to locate and verify some stored data.
class
Verifiable
v
where
-- | Ask a storage server which share numbers related to this capability it
-- is holding. This is an unverified result and the storage server could
-- present incorrect information. Even if it correctly reports that it
-- holds a share, it could decline to give it out when asked.
getShareNumbers
::
MonadIO
m
=>
v
->
StorageServer
->
m
(
Set
.
Set
ShareNum
)
-- | Get the encoding parameters used for the shares of this capability.
-- The information is presented as a tuple of (required, total).
getRequiredTotal
::
MonadIO
m
=>
v
->
StorageServer
->
m
(
Int
,
Int
)
-- | Get the location information for shares of this capability.
getStorageIndex
::
v
->
StorageIndex
instance
Verifiable
CHK
.
Verifier
where
...
...
@@ -108,13 +110,23 @@ instance Verifiable CHK.Verifier where
-- CHK is pure, we don't have to ask the StorageServer
getRequiredTotal
Verifier
{
required
,
total
}
_
=
pure
(
fromIntegral
required
,
fromIntegral
total
)
{- | A capability which confers the ability to interpret some stored data to
recover the original plaintext. Additionally, it can be attentuated to a
Verifiable.
-}
class
(
Verifiable
v
)
=>
Readable
r
v
|
r
->
v
where
-- | Attentuate the capability.
getVerifiable
::
r
->
v
-- | Interpret the required number of shares to recover the plaintext.
--
-- Note: might want to split the two functions below out of decodeShare
--
-- shareToCipherText :: r -> [(Int, WhichShare)] -> LB.ByteString
--
-- cipherTextToPlainText :: r -> LB.ByteString -> LB.ByteString
decodeShare
::
MonadIO
m
=>
r
->
[(
Int
,
WhichShare
)]
->
m
(
Either
DownloadError
LB
.
ByteString
)
-- Might want to split the two functions below out of decodeShare
-- shareToCipherText :: Share ->
-- cipherTextToPlainText
instance
Readable
CHK
.
Reader
CHK
.
Verifier
where
getVerifiable
=
verifier
decodeShare
r
shareList
=
do
...
...
@@ -124,8 +136,15 @@ instance Readable CHK.Reader CHK.Verifier where
Just
ct
->
pure
.
Right
$
Tahoe
.
CHK
.
Encrypt
.
decrypt
(
readKey
r
)
ct
data
WhichShare
=
CHK
{
unWhich
::
Tahoe
.
CHK
.
Share
.
Share
}
-- \| SDMF SDMF.Share
{- | Represent the kind of share to operate on. This forms a closed world of
share types. It might eventually be interesting to make an open world
variation instead.
-}
newtype
WhichShare
=
CHK
{
unWhich
::
Tahoe
.
CHK
.
Share
.
Share
}
-- \| SDMF SDMF.Share
{- | Deserialize some bytes representing some kind of share to that kind of
share, if possible.
-}
bytesToShare
::
LB
.
ByteString
->
Either
DeserializeError
WhichShare
bytesToShare
bytes
=
do
case
decodeOrFail
bytes
of
...
...
This diff is collapsed.
Click to expand it.
src/Tahoe/Download/Internal/Client.hs
+
6
−
0
View file @
24c7db55
{- | Functionality related to acting as a client for the Great Black Swamp
protocol.
-}
module
Tahoe.Download.Internal.Client
where
import
Control.Monad.IO.Class
...
...
@@ -118,4 +121,7 @@ data LookupError
AnnouncementStructureUnmatched
deriving
(
Eq
,
Ord
,
Show
)
{- | A problem was encountered attempting to deserialize bytes to a structured
representation of some value.
-}
data
DeserializeError
=
UnknownDeserializeError
-- add more later?
This diff is collapsed.
Click to expand it.
src/Tahoe/Download/Internal/Immutable.hs
+
4
−
0
View file @
24c7db55
-- | Functionality related to retrieving "immutable" shares (mainly CHK).
module
Tahoe.Download.Internal.Immutable
where
import
Control.Exception
...
...
@@ -58,6 +59,9 @@ announcementToImmutableStorageServer ann =
Nothing
->
pure
.
Left
.
URIParseError
$
ann
Just
uri
->
makeImmutableServer
uri
{- | If possible, populate a StorageServer with functions for operating on
immutable data on the server at the given URI.
-}
makeImmutableServer
::
MonadIO
m
=>
URI
->
m
(
Either
LookupError
StorageServer
)
makeImmutableServer
URI
...
...
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