-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from berty/glouvigny/ipfs_services_as_interface
chore: now using an interface for ipfs services
- Loading branch information
Showing
19 changed files
with
136 additions
and
121 deletions.
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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,50 +1,9 @@ | ||
package io // import "berty.tech/go-ipfs-log/io" | ||
|
||
import ( | ||
bserv "github.com/ipfs/go-blockservice" | ||
datastore "github.com/ipfs/go-datastore" | ||
dssync "github.com/ipfs/go-datastore/sync" | ||
bstore "github.com/ipfs/go-ipfs-blockstore" | ||
offline "github.com/ipfs/go-ipfs-exchange-offline" | ||
ipfs_core "github.com/ipfs/go-ipfs/core" | ||
"github.com/ipfs/go-ipfs/pin" | ||
ipld "github.com/ipfs/go-ipld-format" | ||
merkledag "github.com/ipfs/go-merkledag" | ||
core_iface "github.com/ipfs/interface-go-ipfs-core" | ||
) | ||
|
||
type IpfsServices struct { | ||
DAG ipld.DAGService | ||
BlockStore bstore.Blockstore | ||
DB datastore.Datastore | ||
Blockserv bserv.BlockService | ||
Pinner pin.Pinner | ||
} | ||
|
||
func NewMemoryServices() *IpfsServices { | ||
dataStore := datastore.NewMapDatastore() | ||
db := dssync.MutexWrap(dataStore) | ||
bs := bstore.NewBlockstore(db) | ||
blockserv := bserv.New(bs, offline.Exchange(bs)) | ||
dag := merkledag.NewDAGService(blockserv) | ||
pinner := pin.NewPinner(db, dag, dag) | ||
|
||
// var pinning pin.Pinner = pin.NewPinner() | ||
// var blockstore bstore.GCBlockstore = bstore.NewBlockstore() | ||
return &IpfsServices{ | ||
DAG: dag, | ||
BlockStore: bs, | ||
DB: db, | ||
Blockserv: blockserv, | ||
Pinner: pinner, | ||
} | ||
} | ||
|
||
func FromIpfsNode(node *ipfs_core.IpfsNode, ds datastore.Datastore) *IpfsServices { | ||
return &IpfsServices{ | ||
DAG: node.DAG, | ||
BlockStore: node.Blockstore, | ||
DB: ds, | ||
Blockserv: node.Blocks, | ||
Pinner: node.Pinning, | ||
} | ||
type IpfsServices interface { | ||
Dag() core_iface.APIDagService | ||
} |
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
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
Oops, something went wrong.