sectorbuilder

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2019 License: Apache-2.0, MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MaxNumStagedSectors = 1

MaxNumStagedSectors configures the maximum number of staged sectors which can be open and accepting data at any time.

View Source
const MaxTimeToWriteBytesToSink = time.Second * 30

MaxTimeToWriteBytesToSink configures the maximum amount of time it should take to copy user piece bytes from the provided Reader to the ByteSink.

View Source
const SealedSectorPollingInterval = 1 * time.Second

SealedSectorPollingInterval defines the interval for which we poll through the FFI for sealed sector metadata after adding a piece.

Variables

View Source
var ErrPieceTooLarge = errors.New("piece too large for sector")

ErrPieceTooLarge is an error indicating that a piece cannot be larger than the sector into which it is written.

Functions

func AddressToProverID

func AddressToProverID(addr address.Address) [31]byte

AddressToProverID creates a prover id by padding an address hash to 31 bytes

func NewErrCouldNotRevertUnsealedSector

func NewErrCouldNotRevertUnsealedSector(rollbackErr error, rollbackCause error) error

NewErrCouldNotRevertUnsealedSector produces an ErrCouldNotRevertUnsealedSector.

func SectorIDToBytes

func SectorIDToBytes(sectorID uint64) [31]byte

SectorIDToBytes creates a prover id by padding an address hash to 31 bytes

Types

type ErrCouldNotRevertUnsealedSector

type ErrCouldNotRevertUnsealedSector struct {
	// contains filtered or unexported fields
}

ErrCouldNotRevertUnsealedSector is an error indicating that a revert of an unsealed sector failed due to rollbackErr. This revert was originally triggered by the rollbackCause error

func (*ErrCouldNotRevertUnsealedSector) Error

type GeneratePoStRequest

type GeneratePoStRequest struct {
	CommRs        []proofs.CommR
	ChallengeSeed proofs.PoStChallengeSeed
}

GeneratePoStRequest represents a request to generate a proof-of-spacetime.

type GeneratePoStResponse

type GeneratePoStResponse struct {
	Faults []uint64
	Proofs []proofs.PoStProof
}

GeneratePoStResponse contains PoST proof and any faults that may have occurred.

type PieceInfo

type PieceInfo struct {
	Ref  cid.Cid `json:"ref"`
	Size uint64  `json:"size"` // TODO: use BytesAmount
}

PieceInfo is information about a filecoin piece

type RustSectorBuilder

type RustSectorBuilder struct {
	// contains filtered or unexported fields
}

RustSectorBuilder is a struct which serves as a proxy for a SectorBuilder in Rust.

func NewRustSectorBuilder

func NewRustSectorBuilder(cfg RustSectorBuilderConfig) (*RustSectorBuilder, error)

NewRustSectorBuilder instantiates a SectorBuilder through the FFI.

func (*RustSectorBuilder) AddPiece

func (sb *RustSectorBuilder) AddPiece(ctx context.Context, pieceRef cid.Cid, pieceSize uint64, pieceReader io.Reader) (sectorID uint64, retErr error)

AddPiece writes the given piece into an unsealed sector and returns the id of that sector.

func (*RustSectorBuilder) Close

func (sb *RustSectorBuilder) Close() error

Close shuts down the RustSectorBuilder's poller.

func (*RustSectorBuilder) GeneratePoSt

GeneratePoSt produces a proof-of-spacetime for the provided commitment replicas.

func (*RustSectorBuilder) GetMaxUserBytesPerStagedSector

func (sb *RustSectorBuilder) GetMaxUserBytesPerStagedSector() (numBytes uint64, err error)

GetMaxUserBytesPerStagedSector produces the number of user piece-bytes which will fit into a newly-provisioned staged sector.

func (*RustSectorBuilder) ReadPieceFromSealedSector

func (sb *RustSectorBuilder) ReadPieceFromSealedSector(pieceCid cid.Cid) (io.Reader, error)

ReadPieceFromSealedSector produces a Reader used to get original piece-bytes from a sealed sector.

func (*RustSectorBuilder) SealAllStagedSectors

func (sb *RustSectorBuilder) SealAllStagedSectors(ctx context.Context) error

SealAllStagedSectors schedules sealing of all staged sectors.

func (*RustSectorBuilder) SectorSealResults

func (sb *RustSectorBuilder) SectorSealResults() <-chan SectorSealResult

SectorSealResults returns an unbuffered channel that is sent a value whenever sealing completes.

type RustSectorBuilderConfig

type RustSectorBuilderConfig struct {
	BlockService     bserv.BlockService
	LastUsedSectorID uint64
	MetadataDir      string
	MinerAddr        address.Address
	SealedSectorDir  string
	ProofsMode       proofs.Mode
	StagedSectorDir  string
}

RustSectorBuilderConfig is a configuration object used when instantiating a Rust-backed SectorBuilder through the FFI. All fields are required.

type SealedSectorMetadata

type SealedSectorMetadata struct {
	CommD     proofs.CommD
	CommR     proofs.CommR // deprecated (will be removed soon)
	CommRStar proofs.CommRStar
	Pieces    []*PieceInfo // deprecated (will be removed soon)
	Proof     proofs.SealProof
	SectorID  uint64
}

SealedSectorMetadata is a sector that has been sealed by the PoRep setup process

type SectorBuilder

type SectorBuilder interface {
	// AddPiece writes the given piece into an unsealed sector and returns the
	// id of that sector. This method has a race; it is possible that the
	// sector into which the piece-bytes were written is sealed before this
	// method returns. In the real world this should not happen, as sealing
	// takes a long time to complete. In tests, where sealing happens
	// near-instantaneously, it is possible to exercise this race.
	AddPiece(ctx context.Context, pieceRef cid.Cid, pieceSize uint64, pieceReader io.Reader) (sectorID uint64, err error)

	// ReadPieceFromSealedSector produces a Reader used to get original
	// piece-bytes from a sealed sector.
	ReadPieceFromSealedSector(pieceCid cid.Cid) (io.Reader, error)

	// SealAllStagedSectors seals any non-empty staged sectors.
	SealAllStagedSectors(ctx context.Context) error

	// SectorSealResults returns an unbuffered channel that is sent a value
	// whenever sealing completes. All calls to SectorSealResults will get the
	// same channel. Values will be either a *SealedSectorMetadata or an error.
	// A *SealedSectorMetadata will be sent to the returned channel only once,
	// regardless of the number of times SectorSealResults is called.
	SectorSealResults() <-chan SectorSealResult

	// GetMaxUserBytesPerStagedSector produces the number of user piece-bytes
	// which will fit into a newly-provisioned staged sector.
	GetMaxUserBytesPerStagedSector() (uint64, error)

	// GeneratePoSt creates a proof-of-spacetime for the replicas managed by
	// the SectorBuilder. Its output includes the proof-of-spacetime proof which
	// is posted to the blockchain along with any faults. The proof can be
	// verified by the VerifyPoSt method on the Verifier interface.
	GeneratePoSt(GeneratePoStRequest) (GeneratePoStResponse, error)

	// Close signals that this SectorBuilder is no longer in use. SectorBuilder
	// metadata will not be deleted when Close is called; an equivalent
	// SectorBuilder can be created later by applying the Init function to the
	// arguments used to create the instance being closed.
	Close() error
}

SectorBuilder provides an interface through which user piece-bytes can be written, sealed into sectors, and later unsealed and read.

type SectorSealResult

type SectorSealResult struct {
	SectorID uint64

	// SealingErr contains any error encountered while sealing.
	// Note: Either SealingResult or SealingErr may be non-nil, not both.
	SealingErr error

	// SealingResult contains the successful output of the sealing operation.
	// Note: Either SealingResult or SealingErr may be non-nil, not both.
	SealingResult *SealedSectorMetadata
}

SectorSealResult represents the outcome of a sector's sealing.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL