mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-05 00:08:06 +08:00
add a BigFileStore to the CoreAPI; still needs initialization logic of the big file store (now placeholder)
This commit is contained in:
parent
50166a586a
commit
faf37c4f84
@ -19,11 +19,11 @@ import (
|
||||
"fmt"
|
||||
|
||||
bserv "github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-ipfs-blockstore"
|
||||
"github.com/ipfs/go-ipfs-exchange-interface"
|
||||
blockstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
exchange "github.com/ipfs/go-ipfs-exchange-interface"
|
||||
offlinexch "github.com/ipfs/go-ipfs-exchange-offline"
|
||||
"github.com/ipfs/go-ipfs-pinner"
|
||||
"github.com/ipfs/go-ipfs-provider"
|
||||
pin "github.com/ipfs/go-ipfs-pinner"
|
||||
provider "github.com/ipfs/go-ipfs-provider"
|
||||
offlineroute "github.com/ipfs/go-ipfs-routing/offline"
|
||||
ipld "github.com/ipfs/go-ipld-format"
|
||||
dag "github.com/ipfs/go-merkledag"
|
||||
@ -38,6 +38,7 @@ import (
|
||||
record "github.com/libp2p/go-libp2p-record"
|
||||
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
"github.com/ipfs/go-ipfs/core/coreunix"
|
||||
"github.com/ipfs/go-ipfs/core/node"
|
||||
"github.com/ipfs/go-ipfs/namesys"
|
||||
"github.com/ipfs/go-ipfs/repo"
|
||||
@ -56,6 +57,7 @@ type CoreAPI struct {
|
||||
|
||||
blocks bserv.BlockService
|
||||
dag ipld.DAGService
|
||||
bfs *coreunix.BigFileStore //XXX
|
||||
|
||||
peerstore pstore.Peerstore
|
||||
peerHost p2phost.Host
|
||||
@ -167,6 +169,7 @@ func (api *CoreAPI) WithOptions(opts ...options.ApiOption) (coreiface.CoreAPI, e
|
||||
|
||||
blocks: n.Blocks,
|
||||
dag: n.DAG,
|
||||
bfs: nil, // XXX: initialize big file store, e.g. coreunix.NewBigFileStore(???),
|
||||
|
||||
peerstore: n.Peerstore,
|
||||
peerHost: n.PeerHost,
|
||||
|
||||
@ -119,7 +119,7 @@ func (api *UnixfsAPI) Add(ctx context.Context, files files.Node, opts ...options
|
||||
}
|
||||
}
|
||||
|
||||
fileAdder, err := coreunix.NewAdder(ctx, pinning, addblockstore, syncDserv)
|
||||
fileAdder, err := coreunix.NewAdder(ctx, pinning, addblockstore, syncDserv, api.bfs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ type syncer interface {
|
||||
}
|
||||
|
||||
// NewAdder Returns a new Adder used for a file add operation.
|
||||
func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCLocker, ds ipld.DAGService) (*Adder, error) {
|
||||
func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCLocker, ds ipld.DAGService, bfs *BigFileStore) (*Adder, error) {
|
||||
bufferedDS := ipld.NewBufferedDAG(ctx, ds)
|
||||
|
||||
return &Adder{
|
||||
@ -55,6 +55,7 @@ func NewAdder(ctx context.Context, p pin.Pinner, bs bstore.GCLocker, ds ipld.DAG
|
||||
gcLocker: bs,
|
||||
dagService: ds,
|
||||
bufferedDS: bufferedDS,
|
||||
bfs: bfs,
|
||||
Progress: false,
|
||||
Pin: true,
|
||||
Trickle: false,
|
||||
@ -69,6 +70,7 @@ type Adder struct {
|
||||
gcLocker bstore.GCLocker
|
||||
dagService ipld.DAGService
|
||||
bufferedDS *ipld.BufferedDAG
|
||||
bfs *BigFileStore
|
||||
Out chan<- interface{}
|
||||
Progress bool
|
||||
Pin bool
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
dshelp "github.com/ipfs/go-ipfs-ds-help"
|
||||
)
|
||||
|
||||
type bigFileStore struct {
|
||||
type BigFileStore struct {
|
||||
dstore ds.Datastore
|
||||
}
|
||||
|
||||
@ -15,13 +15,13 @@ type bigFileStore struct {
|
||||
var bigFilePrefix = ds.NewKey("bigfiles")
|
||||
|
||||
// NewBigFileStore creates a new bifFileStore
|
||||
func NewBigFileStore(dstore ds.Datastore) *bigFileStore {
|
||||
return &bigFileStore{
|
||||
func NewBigFileStore(dstore ds.Datastore) *BigFileStore {
|
||||
return &BigFileStore{
|
||||
dstore: dsns.Wrap(dstore, bigFilePrefix),
|
||||
}
|
||||
}
|
||||
|
||||
func (b *bigFileStore) Put(streamCid cid.Cid, chunks []*ChunkingManifestChunk) error {
|
||||
func (b *BigFileStore) Put(streamCid cid.Cid, chunks []*ChunkingManifestChunk) error {
|
||||
chunkData, err := serializeChunks(chunks)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -31,7 +31,7 @@ func (b *bigFileStore) Put(streamCid cid.Cid, chunks []*ChunkingManifestChunk) e
|
||||
return b.dstore.Put(dsk, chunkData)
|
||||
}
|
||||
|
||||
func (b *bigFileStore) Get(streamCid cid.Cid) ([]*ChunkingManifestChunk, error) {
|
||||
func (b *BigFileStore) Get(streamCid cid.Cid) ([]*ChunkingManifestChunk, error) {
|
||||
data, err := b.dstore.Get(dshelp.CidToDsKey(streamCid))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Loading…
Reference in New Issue
Block a user