sectorbuilder

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0, MIT Imports: 18 Imported by: 1

README

go-sectorbuilder

An abstraction used to manage a storage miner's sectors

License

Dual-licensed under MIT + Apache 2.0

Documentation

Index

Constants

View Source
const MaxFallbackPostChallengeCount = 10
View Source
const PoRepProofPartitions = 10
View Source
const PoStReservedWorkers = 1
View Source
const SectorChallengeRatioDiv = 25

1 / n

Variables

View Source
var ProofVerifier = proofVerifier{}

Functions

func ElectionPostChallengeCount

func ElectionPostChallengeCount(sectors uint64, faults uint64) uint64

extracted from lotus/chain/types/blockheader

func GenerateDataCommitment

func GenerateDataCommitment(ssize uint64, pieces []sectorbuilder.PublicPieceInfo) ([CommLen]byte, error)

func GeneratePieceCommitment

func GeneratePieceCommitment(piece io.Reader, pieceSize uint64) (commP [CommLen]byte, err error)

Types

type Config

type Config struct {
	SectorSize uint64
	Miner      address.Address

	WorkerThreads  uint8
	FallbackLastID uint64
	NoCommit       bool
	NoPreCommit    bool

	Dir string
	// contains filtered or unexported fields
}

type EPostCandidate

type EPostCandidate = sectorbuilder.Candidate

type Fault

type Fault struct {
	SectorID uint64

	Err error
}

type Interface

type Interface interface {
	RateLimit() func()
	AddPiece(uint64, uint64, io.Reader, []uint64) (PublicPieceInfo, error)
	SectorSize() uint64
	AcquireSectorId() (uint64, error)
	Scrub(SortedPublicSectorInfo) []*Fault

	GenerateEPostCandidates(sectorInfo SortedPublicSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]EPostCandidate, error)
	GenerateFallbackPoSt(SortedPublicSectorInfo, [CommLen]byte, []uint64) ([]EPostCandidate, []byte, error)
	ComputeElectionPoSt(sectorInfo SortedPublicSectorInfo, challengeSeed []byte, winners []EPostCandidate) ([]byte, error)

	SealPreCommit(context.Context, uint64, SealTicket, []PublicPieceInfo) (RawSealPreCommitOutput, error)
	SealCommit(context.Context, uint64, SealTicket, SealSeed, []PublicPieceInfo, RawSealPreCommitOutput) ([]byte, error)

	ReadPieceFromSealedSector(sectorID uint64, offset uint64, size uint64, ticket []byte, commD []byte) (io.ReadCloser, error)

	GetPath(string, string) (string, error)
	WorkerStats() WorkerStats
	AddWorker(context.Context, WorkerCfg) (<-chan WorkerTask, error)
	TaskDone(context.Context, uint64, SealRes) error
}

type JsonRSPCO

type JsonRSPCO struct {
	CommD []byte
	CommR []byte
}

type PublicPieceInfo

type PublicPieceInfo = sectorbuilder.PublicPieceInfo

type RawSealPreCommitOutput

type RawSealPreCommitOutput sectorbuilder.RawSealPreCommitOutput

func (*RawSealPreCommitOutput) ToJson

func (rspco *RawSealPreCommitOutput) ToJson() JsonRSPCO

type SealCommitOutput

type SealCommitOutput = sectorbuilder.SealCommitOutput

type SealPreCommitOutput

type SealPreCommitOutput = sectorbuilder.SealPreCommitOutput

type SealRes

type SealRes struct {
	Err   string
	GoErr error `json:"-"`

	Proof []byte
	Rspco JsonRSPCO
}

type SealSeed

type SealSeed = sectorbuilder.SealSeed

type SealTicket

type SealTicket = sectorbuilder.SealTicket

type SectorBuilder

type SectorBuilder struct {
	Miner address.Address
	// contains filtered or unexported fields
}

func New

func New(cfg *Config, ds datastore.Batching) (*SectorBuilder, error)

func NewStandalone

func NewStandalone(cfg *Config) (*SectorBuilder, error)

func TempSectorbuilderDir

func TempSectorbuilderDir(dir string, sectorSize uint64, ds datastore.Batching) (*SectorBuilder, error)

func (*SectorBuilder) AcquireSectorId

func (sb *SectorBuilder) AcquireSectorId() (uint64, error)

func (*SectorBuilder) AddPiece

func (sb *SectorBuilder) AddPiece(pieceSize uint64, sectorId uint64, file io.Reader, existingPieceSizes []uint64) (PublicPieceInfo, error)

func (*SectorBuilder) AddWorker

func (sb *SectorBuilder) AddWorker(ctx context.Context, cfg WorkerCfg) (<-chan WorkerTask, error)

func (*SectorBuilder) ComputeElectionPoSt

func (sb *SectorBuilder) ComputeElectionPoSt(sectorInfo SortedPublicSectorInfo, challengeSeed []byte, winners []EPostCandidate) ([]byte, error)

func (*SectorBuilder) GenerateEPostCandidates

func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]EPostCandidate, error)

func (*SectorBuilder) GenerateFallbackPoSt

func (sb *SectorBuilder) GenerateFallbackPoSt(sectorInfo SortedPublicSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]EPostCandidate, []byte, error)

func (*SectorBuilder) GetPath

func (sb *SectorBuilder) GetPath(typ string, sectorName string) (string, error)

func (*SectorBuilder) ImportFrom

func (sb *SectorBuilder) ImportFrom(osb *SectorBuilder, symlink bool) error

func (*SectorBuilder) RateLimit

func (sb *SectorBuilder) RateLimit() func()

func (*SectorBuilder) ReadPieceFromSealedSector

func (sb *SectorBuilder) ReadPieceFromSealedSector(sectorID uint64, offset uint64, size uint64, ticket []byte, commD []byte) (io.ReadCloser, error)

func (*SectorBuilder) Scrub

func (sb *SectorBuilder) Scrub(sectorSet sectorbuilder.SortedPublicSectorInfo) []*Fault

func (*SectorBuilder) SealCommit

func (sb *SectorBuilder) SealCommit(ctx context.Context, sectorID uint64, ticket SealTicket, seed SealSeed, pieces []PublicPieceInfo, rspco RawSealPreCommitOutput) (proof []byte, err error)

func (*SectorBuilder) SealPreCommit

func (sb *SectorBuilder) SealPreCommit(ctx context.Context, sectorID uint64, ticket SealTicket, pieces []PublicPieceInfo) (RawSealPreCommitOutput, error)

func (*SectorBuilder) SealedSectorPath

func (sb *SectorBuilder) SealedSectorPath(sectorID uint64) (string, error)

func (*SectorBuilder) SectorName

func (sb *SectorBuilder) SectorName(sectorID uint64) string

func (*SectorBuilder) SectorSize

func (sb *SectorBuilder) SectorSize() uint64

func (*SectorBuilder) SetLastSectorID

func (sb *SectorBuilder) SetLastSectorID(id uint64) error

func (*SectorBuilder) StagedSectorPath

func (sb *SectorBuilder) StagedSectorPath(sectorID uint64) string

func (*SectorBuilder) Stop

func (sb *SectorBuilder) Stop()

func (*SectorBuilder) TaskDone

func (sb *SectorBuilder) TaskDone(ctx context.Context, task uint64, res SealRes) error

func (*SectorBuilder) TrimCache

func (sb *SectorBuilder) TrimCache(sectorID uint64) error

func (*SectorBuilder) WorkerStats

func (sb *SectorBuilder) WorkerStats() WorkerStats

type SortedPrivateSectorInfo

type SortedPrivateSectorInfo = sectorbuilder.SortedPrivateSectorInfo

type SortedPublicSectorInfo

type SortedPublicSectorInfo = sectorbuilder.SortedPublicSectorInfo

func NewSortedPublicSectorInfo

func NewSortedPublicSectorInfo(sectors []sectorbuilder.PublicSectorInfo) SortedPublicSectorInfo

type Verifier

type Verifier interface {
	VerifyElectionPost(ctx context.Context, sectorSize uint64, sectorInfo SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []EPostCandidate, proverID address.Address) (bool, error)
	VerifyFallbackPost(ctx context.Context, sectorSize uint64, sectorInfo SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []EPostCandidate, proverID address.Address, faults uint64) (bool, error)
	VerifySeal(sectorSize uint64, commR, commD []byte, proverID address.Address, ticket []byte, seed []byte, sectorID uint64, proof []byte) (bool, error)
}

type WorkerCfg

type WorkerCfg struct {
	NoPreCommit bool
	NoCommit    bool
}

type WorkerStats

type WorkerStats struct {
	LocalFree     int
	LocalReserved int
	LocalTotal    int
	// todo: post in progress
	RemotesTotal int
	RemotesFree  int

	AddPieceWait  int
	PreCommitWait int
	CommitWait    int
	UnsealWait    int
}

type WorkerTask

type WorkerTask struct {
	Type   WorkerTaskType
	TaskID uint64

	SectorID uint64

	// preCommit
	SealTicket SealTicket
	Pieces     []PublicPieceInfo

	// commit
	SealSeed SealSeed
	Rspco    RawSealPreCommitOutput
}

type WorkerTaskType

type WorkerTaskType int
const (
	WorkerPreCommit WorkerTaskType = iota
	WorkerCommit
)

Jump to

Keyboard shortcuts

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