Documentation ¶
Index ¶
Constants ¶
const ( // SFRegistered corresponds to Registered SFRegistered WorkSpaceStateFlags = 1 << iota // SFPlotting corresponds to Plotting SFPlotting // SFReady corresponds to Ready SFReady // SFMining corresponds to Mining SFMining // FirstStateFlags hints the value of first StateFlag FirstStateFlags = SFRegistered // LastStateFlags hints the value of last StateFlag LastStateFlags = SFMining // SFAll is a convenient way of setting all flags SFAll = SFRegistered | SFPlotting | SFReady | SFMining )
Here lists the state flags of a WorkSpace.
const ( // UnknownOrdinal indicates that the ordinal of PocDB is unknown or non-existent UnknownOrdinal int64 = -1 )
Variables ¶
var ( // ErrInvalidState indicates invalid WorkSpaceState ErrInvalidState = errors.New("invalid state") // ErrNoneStateFlags indicates none WorkSpaceStateFlags ErrNoneStateFlags = errors.New("workspace state flag is none") )
var ( // ErrInvalidAction indicates invalid action ErrInvalidAction = errors.New("invalid action") // ErrUnImplementedAction indicates unimplemented action ErrUnImplementedAction = errors.New("unimplemented action") )
var ( // ErrProofIOTimeout indicates proof read/write operation timeout ErrProofIOTimeout = errors.New("proof i/o timeout") )
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType uint8
ActionType represents the action acted on WorkSpace
const ( // Plot should make WorkSpace state conversion happen like: // registered -> plotting -> ready // registered -> ready // plotting -> ready // ready -> ready // mining -> mining // WorkSpace is not allowed to plot unless its state is registered, plotting, ready or mining Plot ActionType = iota // Mine should make WorkSpace state conversion happen like: // registered -> plotting -> mining // plotting -> mining // ready -> mining // mining -> mining // WorkSpace is not allowed to mine unless its state is registered, plotting, ready or mining Mine // Stop should make WorkSpace state conversion happen like: // registered -> registered // plotting -> registered // ready -> ready // mining -> ready // WorkSpace is not allowed to stop unless its state is registered, plotting, ready or mining Stop // Remove should remove index of WorkSpace // WorkSpace is not allowed to remove unless its state is registered or ready Remove // Delete should delete both index and data of WorkSpace // WorkSpace is not allowed to delete unless its state is registered or ready Delete // FirstAction hints the value of first ActionType FirstAction = Plot // LastAction hints the value of last ActionType LastAction = Delete )
func (ActionType) IsValid ¶
func (act ActionType) IsValid() bool
IsValid reports whether current action is defined or not
func (ActionType) String ¶
func (act ActionType) String() string
type ProofRW ¶
type ProofRW struct {
// contains filtered or unexported fields
}
ProofRW implements ProofReader and provides a way that servers can writes WorkSpaceProofs.
func NewProofRW ¶
NewProofRW generates a new ProofRW instance.
func (*ProofRW) Close ¶
func (prw *ProofRW) Close()
Close closes ProofRW.
Any call to Write would get ErrProofIOTimeout.
func (*ProofRW) Read ¶
func (prw *ProofRW) Read() (*WorkSpaceProof, error)
Read implements ProofReader.
func (*ProofRW) Write ¶
func (prw *ProofRW) Write(wsp *WorkSpaceProof) error
Write provides a way that servers can writes WorkSpaceProofs.
Write is concurrent safe, and returns an error ErrProofIOTimeout if p.ctx is Done.
type ProofReader ¶
type ProofReader interface {
Read() (*WorkSpaceProof, error)
}
ProofReader is the interface that wraps the basic Read-Proof method.
An instance of this general case is that a ProofReader returning a non-nil WorkSpaceProof at the end of the input stream may return either err == io.EOF or err == nil. The next Read should return nil, io.EOF.
type WorkSpaceInfo ¶
type WorkSpaceInfo struct { SpaceID string PublicKey *pocec.PublicKey Ordinal int64 BitLength int Progress float64 State WorkSpaceState }
WorkSpaceInfo represents the general info of a WorkSpace
type WorkSpaceProof ¶
type WorkSpaceProof struct { SpaceID string Proof *poc.Proof PublicKey *pocec.PublicKey Ordinal int64 Error error }
WorkSpaceProof contains poc.Proof along with other elements helping miner, Proof is nil when Error is not nil
type WorkSpaceState ¶
type WorkSpaceState uint32
WorkSpaceState represents the state of a WorkSpace according to its ability
const ( // Registered indicates SpaceKeeper has registered a (PK, BitLength), // no matter whether it has been loaded or plotted Registered WorkSpaceState = iota // Plotting indicates a (PK, BitLength) instance is plotting or loading Plotting // Ready indicates a (PK, BitLength) instance is loaded (also plotted), // thus the space is ready for mining Ready // Mining indicates a (PK, BitLength) instance is used for mining Mining // FirstState hints the first state FirstState = Registered // LastState hints the last state LastState = Mining )
Here lists the states of a WorkSpace.
func (WorkSpaceState) Flag ¶
func (s WorkSpaceState) Flag() WorkSpaceStateFlags
Flag converts current state to corresponding WorkSpaceStateFlags
func (WorkSpaceState) IsValid ¶
func (s WorkSpaceState) IsValid() bool
IsValid reports whether current state is defined or not
func (WorkSpaceState) String ¶
func (s WorkSpaceState) String() string
type WorkSpaceStateFlags ¶
type WorkSpaceStateFlags WorkSpaceState
WorkSpaceStateFlags represents the flags of a WorkSpace state
func (WorkSpaceStateFlags) Contains ¶
func (f WorkSpaceStateFlags) Contains(flag WorkSpaceStateFlags) bool
Contains reports whether current flags contains given flags
func (WorkSpaceStateFlags) IsNone ¶
func (f WorkSpaceStateFlags) IsNone() bool
IsNone reports whether none of a defined flag is set or not
func (WorkSpaceStateFlags) States ¶
func (f WorkSpaceStateFlags) States() []WorkSpaceState
States returns a slice of WorkSpaceStates contained in current flags by ascending order
func (WorkSpaceStateFlags) String ¶
func (f WorkSpaceStateFlags) String() string
Format as "SFAll", "SFAll|SFReady" and "SFNone"