-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/harmonystorage' of https://github.com/filecoin-pro…
…ject/lotus into feat/harmonystorage
- Loading branch information
Showing
116 changed files
with
10,072 additions
and
1,472 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 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,10 +1,28 @@ | ||
package api | ||
|
||
import "context" | ||
import ( | ||
"context" | ||
"net/http" | ||
"net/url" | ||
|
||
"github.com/filecoin-project/go-address" | ||
|
||
"github.com/filecoin-project/lotus/storage/sealer/fsutil" | ||
"github.com/filecoin-project/lotus/storage/sealer/storiface" | ||
) | ||
|
||
type LotusProvider interface { | ||
Version(context.Context) (Version, error) //perm:admin | ||
|
||
AllocatePieceToSector(ctx context.Context, maddr address.Address, piece PieceDealInfo, rawSize int64, source url.URL, header http.Header) (SectorOffset, error) //perm:write | ||
|
||
StorageAddLocal(ctx context.Context, path string) error //perm:admin | ||
StorageDetachLocal(ctx context.Context, path string) error //perm:admin | ||
StorageList(ctx context.Context) (map[storiface.ID][]storiface.Decl, error) //perm:admin | ||
StorageLocal(ctx context.Context) (map[storiface.ID]string, error) //perm:admin | ||
StorageStat(ctx context.Context, id storiface.ID) (fsutil.FsStat, error) //perm:admin | ||
StorageInfo(context.Context, storiface.ID) (storiface.StorageInfo, error) //perm:admin | ||
|
||
// Trigger shutdown | ||
Shutdown(context.Context) error //perm:admin | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package blockstore | ||
|
||
import ( | ||
"context" | ||
|
||
blocks "github.com/ipfs/go-block-format" | ||
"github.com/ipfs/go-cid" | ||
) | ||
|
||
// BlockstoreCache is a cache for blocks, compatible with lru.Cache; Must be safe for concurrent access | ||
type BlockstoreCache interface { | ||
Remove(mhString MhString) bool | ||
Contains(mhString MhString) bool | ||
Get(mhString MhString) (blocks.Block, bool) | ||
Add(mhString MhString, block blocks.Block) (evicted bool) | ||
} | ||
|
||
type ReadCachedBlockstore struct { | ||
top Blockstore | ||
cache BlockstoreCache | ||
} | ||
|
||
type MhString string | ||
|
||
func NewReadCachedBlockstore(top Blockstore, cache BlockstoreCache) *ReadCachedBlockstore { | ||
return &ReadCachedBlockstore{ | ||
top: top, | ||
cache: cache, | ||
} | ||
} | ||
|
||
func (c *ReadCachedBlockstore) DeleteBlock(ctx context.Context, cid cid.Cid) error { | ||
c.cache.Remove(MhString(cid.Hash())) | ||
return c.top.DeleteBlock(ctx, cid) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) Has(ctx context.Context, cid cid.Cid) (bool, error) { | ||
if c.cache.Contains(MhString(cid.Hash())) { | ||
return true, nil | ||
} | ||
|
||
return c.top.Has(ctx, cid) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) Get(ctx context.Context, cid cid.Cid) (blocks.Block, error) { | ||
if out, ok := c.cache.Get(MhString(cid.Hash())); ok { | ||
return out, nil | ||
} | ||
|
||
out, err := c.top.Get(ctx, cid) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
c.cache.Add(MhString(cid.Hash()), out) | ||
return out, nil | ||
} | ||
|
||
func (c *ReadCachedBlockstore) GetSize(ctx context.Context, cid cid.Cid) (int, error) { | ||
if b, ok := c.cache.Get(MhString(cid.Hash())); ok { | ||
return len(b.RawData()), nil | ||
} | ||
|
||
return c.top.GetSize(ctx, cid) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) Put(ctx context.Context, block blocks.Block) error { | ||
c.cache.Add(MhString(block.Cid().Hash()), block) | ||
return c.top.Put(ctx, block) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error { | ||
for _, b := range blocks { | ||
c.cache.Add(MhString(b.Cid().Hash()), b) | ||
} | ||
|
||
return c.top.PutMany(ctx, blocks) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) { | ||
return c.top.AllKeysChan(ctx) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) HashOnRead(enabled bool) { | ||
c.top.HashOnRead(enabled) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) View(ctx context.Context, cid cid.Cid, callback func([]byte) error) error { | ||
return c.top.View(ctx, cid, func(bb []byte) error { | ||
blk, err := blocks.NewBlockWithCid(bb, cid) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
c.cache.Add(MhString(cid.Hash()), blk) | ||
|
||
return callback(bb) | ||
}) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) DeleteMany(ctx context.Context, cids []cid.Cid) error { | ||
for _, ci := range cids { | ||
c.cache.Remove(MhString(ci.Hash())) | ||
} | ||
|
||
return c.top.DeleteMany(ctx, cids) | ||
} | ||
|
||
func (c *ReadCachedBlockstore) Flush(ctx context.Context) error { | ||
return c.top.Flush(ctx) | ||
} | ||
|
||
var _ Blockstore = (*ReadCachedBlockstore)(nil) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,9 @@ | ||
/dns4/bootstrap-0.mainnet.filops.net/tcp/1347/p2p/12D3KooWCVe8MmsEMes2FzgTpt9fXtmCY7wrq91GRiaC8PHSCCBj | ||
/dns4/bootstrap-1.mainnet.filops.net/tcp/1347/p2p/12D3KooWCwevHg1yLCvktf2nvLu7L9894mcrJR4MsBCcm4syShVc | ||
/dns4/bootstrap-2.mainnet.filops.net/tcp/1347/p2p/12D3KooWEWVwHGn2yR36gKLozmb4YjDJGerotAPGxmdWZx2nxMC4 | ||
/dns4/bootstrap-6.mainnet.filops.net/tcp/1347/p2p/12D3KooWP5MwCiqdMETF9ub1P3MbCvQCcfconnYHbWg6sUJcDRQQ | ||
/dns4/bootstrap-7.mainnet.filops.net/tcp/1347/p2p/12D3KooWRs3aY1p3juFjPy8gPN95PEQChm2QKGUCAdcDCC4EBMKf | ||
/dns4/bootstrap-8.mainnet.filops.net/tcp/1347/p2p/12D3KooWScFR7385LTyR4zU1bYdzSiiAb5rnNABfVahPvVSzyTkR | ||
/dns4/lotus-bootstrap.ipfsforce.com/tcp/41778/p2p/12D3KooWGhufNmZHF3sv48aQeS13ng5XVJZ9E6qy2Ms4VzqeUsHk | ||
/dns4/bootstrap-0.starpool.in/tcp/12757/p2p/12D3KooWGHpBMeZbestVEWkfdnC9u7p6uFHXL1n7m1ZBqsEmiUzz | ||
/dns4/bootstrap-1.starpool.in/tcp/12757/p2p/12D3KooWQZrGH1PxSNZPum99M1zNvjNFM33d1AAu5DcvdHptuU7u | ||
/dns4/node.glif.io/tcp/1235/p2p/12D3KooWBF8cpp65hp2u9LK5mh19x67ftAam84z9LsfaquTDSBpt | ||
/dns4/bootstarp-0.1475.io/tcp/61256/p2p/12D3KooWRzCVDwHUkgdK7eRgnoXbjDAELhxPErjHzbRLguSV1aRt | ||
/dns4/bootstrap-venus.mainnet.filincubator.com/tcp/8888/p2p/QmQu8C6deXwKvJP2D8B6QGyhngc3ZiDnFzEHBDx8yeBXST | ||
/dns4/bootstrap-mainnet-0.chainsafe-fil.io/tcp/34000/p2p/12D3KooWKKkCZbcigsWTEu1cgNetNbZJqeNtysRtFpq7DTqw3eqH | ||
/dns4/bootstrap-mainnet-1.chainsafe-fil.io/tcp/34000/p2p/12D3KooWGnkd9GQKo3apkShQDaq1d6cKJJmsVe6KiQkacUk1T8oZ | ||
/dns4/bootstrap-mainnet-2.chainsafe-fil.io/tcp/34000/p2p/12D3KooWHQRSDFv4FvAjtU32shQ7znz7oRbLBryXzZ9NMK2feyyH |
Oops, something went wrong.