Correctly construct sealbstore
This commit is contained in:
parent
9691211df1
commit
e0dc17bc1a
@ -3,6 +3,7 @@ package node
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/filecoin-project/go-lotus/storage/sealedbstore"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
@ -232,6 +233,7 @@ func Online() Option {
|
||||
ApplyIf(func(s *Settings) bool { return s.nodeType == nodeStorageMiner },
|
||||
Override(new(*sectorbuilder.SectorBuilder), sectorbuilder.New),
|
||||
Override(new(*sector.Store), sector.NewStore),
|
||||
Override(new(*sealedbstore.Sealedbstore), sealedbstore.NewSealedbstore),
|
||||
Override(new(*storage.Miner), modules.StorageMiner),
|
||||
|
||||
Override(new(dtypes.StagingDAG), modules.StagingDAG),
|
||||
|
@ -7,14 +7,15 @@ import (
|
||||
)
|
||||
|
||||
type QueryResponse int
|
||||
|
||||
const (
|
||||
Available QueryResponse = iota
|
||||
Unavailable
|
||||
)
|
||||
|
||||
type RetDealProposal struct {
|
||||
Piece cid.Cid
|
||||
Price types.BigInt
|
||||
Piece cid.Cid
|
||||
Price types.BigInt
|
||||
Payment types.SignedVoucher
|
||||
}
|
||||
|
||||
@ -27,5 +28,3 @@ type RetQueryResponse struct {
|
||||
|
||||
MinPricePerMiB types.BigInt // TODO: check units used for sector size
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package sealedbstore
|
||||
|
||||
import (
|
||||
"github.com/filecoin-project/go-lotus/node/modules/dtypes"
|
||||
"github.com/ipfs/go-datastore/namespace"
|
||||
"sync"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
@ -18,21 +20,30 @@ const (
|
||||
SerializationUnixfs0 SealSerialization = 'u'
|
||||
)
|
||||
|
||||
var dsPrefix = datastore.NewKey("/sealedblocks")
|
||||
|
||||
type SealedRef struct {
|
||||
Serialization SealSerialization
|
||||
|
||||
Piece cid.Cid
|
||||
Piece cid.Cid
|
||||
Offset uint64
|
||||
Size uint32
|
||||
Size uint32
|
||||
}
|
||||
|
||||
type Sealedbstore struct {
|
||||
*sector.Store
|
||||
|
||||
keys datastore.Batching
|
||||
keys datastore.Batching
|
||||
keyLk sync.Mutex
|
||||
}
|
||||
|
||||
func NewSealedbstore(sectst *sector.Store, ds dtypes.MetadataDS) *Sealedbstore {
|
||||
return &Sealedbstore{
|
||||
Store: sectst,
|
||||
keys: namespace.Wrap(ds, dsPrefix),
|
||||
}
|
||||
}
|
||||
|
||||
type UnixfsReader interface {
|
||||
files.File
|
||||
|
||||
@ -43,9 +54,9 @@ type UnixfsReader interface {
|
||||
|
||||
type refStorer struct {
|
||||
blockReader UnixfsReader
|
||||
writeRef func(cid cid.Cid, offset uint64, size uint32) error
|
||||
writeRef func(cid cid.Cid, offset uint64, size uint32) error
|
||||
|
||||
pieceRef string
|
||||
pieceRef string
|
||||
remaining []byte
|
||||
}
|
||||
|
||||
@ -114,7 +125,7 @@ func (st *Sealedbstore) AddUnixfsPiece(ref cid.Cid, r UnixfsReader, keepAtLeast
|
||||
return 0, err
|
||||
}
|
||||
|
||||
refst := &refStorer{blockReader: r, pieceRef: string(SerializationUnixfs0)+ref.String(), writeRef: st.writeRef}
|
||||
refst := &refStorer{blockReader: r, pieceRef: string(SerializationUnixfs0) + ref.String(), writeRef: st.writeRef}
|
||||
|
||||
return st.Store.AddPiece(refst.pieceRef, uint64(size), refst)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user