Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
e0e856aa
Commit
e0e856aa
authored
Jan 21, 2018
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data storage interfaces
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
ce57a766
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletion
+38
-1
blocks/blockstore/blockstore.go
blocks/blockstore/blockstore.go
+7
-0
blockservice/blockservice.go
blockservice/blockservice.go
+14
-1
repo/repo.go
repo/repo.go
+17
-0
No files found.
blocks/blockstore/blockstore.go
View file @
e0e856aa
...
...
@@ -40,12 +40,19 @@ type Blockstore interface {
DeleteBlock
(
*
cid
.
Cid
)
error
Has
(
*
cid
.
Cid
)
(
bool
,
error
)
Get
(
*
cid
.
Cid
)
(
blocks
.
Block
,
error
)
// Put puts a given block to the underlying datastore
Put
(
blocks
.
Block
)
error
// PutMany puts a slice of blocks at the same time using batching
// capabilities of the underlying datastore whenever possible.
PutMany
([]
blocks
.
Block
)
error
// AllKeysChan returns a channel from which
// the CIDs in the Blockstore can be read. It should respect
// the given context, closing the channel if it becomes Done.
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
*
cid
.
Cid
,
error
)
// HashOnRead specifies if every read block should be
// rehashed to make sure it matches its CID.
HashOnRead
(
enabled
bool
)
...
...
blockservice/blockservice.go
View file @
e0e856aa
...
...
@@ -25,13 +25,26 @@ var ErrNotFound = errors.New("blockservice: key not found")
// datastore and may retrieve data from a remote Exchange.
// It uses an internal `datastore.Datastore` instance to store values.
type
BlockService
interface
{
// Blockstore returns a reference to the underlying blockstore
Blockstore
()
blockstore
.
Blockstore
// Exchange returns a reference to the underlying exchange (usually bitswap)
Exchange
()
exchange
.
Interface
// AddBlock puts a given block to the underlying datastore
AddBlock
(
o
blocks
.
Block
)
(
*
cid
.
Cid
,
error
)
// AddBlocks adds a slice of blocks at the same time using batching
// capabilities of the underlying datastore whenever possible.
AddBlocks
(
bs
[]
blocks
.
Block
)
([]
*
cid
.
Cid
,
error
)
GetBlock
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
(
blocks
.
Block
,
error
)
GetBlocks
(
ctx
context
.
Context
,
ks
[]
*
cid
.
Cid
)
<-
chan
blocks
.
Block
DeleteBlock
(
o
blocks
.
Block
)
error
// GetBlocks does a batch request for the given cids, returning blocks as
// they are found, in no particular order.
GetBlocks
(
ctx
context
.
Context
,
ks
[]
*
cid
.
Cid
)
<-
chan
blocks
.
Block
Close
()
error
}
...
...
repo/repo.go
View file @
e0e856aa
...
...
@@ -16,24 +16,41 @@ var (
ErrApiNotRunning
=
errors
.
New
(
"api not running"
)
)
// Repo represents all persistent data of a given ipfs node.
type
Repo
interface
{
// Config returns the ipfs configuration file from the repo. Changes made
// to the returned config are not automatically persisted.
Config
()
(
*
config
.
Config
,
error
)
// BackupConfig creates a backup of the current configuration file using
// the given prefix for naming.
BackupConfig
(
prefix
string
)
(
string
,
error
)
// SetConfig persists the given configuration struct to storage.
SetConfig
(
*
config
.
Config
)
error
// SetConfigKey sets the given key-value pair within the config and persists it to storage.
SetConfigKey
(
key
string
,
value
interface
{})
error
// GetConfigKey reads the value for the given key from the configuration in storage.
GetConfigKey
(
key
string
)
(
interface
{},
error
)
// Datastore returns a reference to the configured data storage backend.
Datastore
()
Datastore
// GetStorageUsage returns the number of bytes stored.
GetStorageUsage
()
(
uint64
,
error
)
// Keystore returns a reference to the key management interface.
Keystore
()
keystore
.
Keystore
// FileManager returns a reference to the filestore file manager.
FileManager
()
*
filestore
.
FileManager
// SetAPIAddr sets the API address in the repo.
SetAPIAddr
(
addr
ma
.
Multiaddr
)
error
// SwarmKey returns the configured shared symmetric key for the private networks feature.
SwarmKey
()
([]
byte
,
error
)
io
.
Closer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment