Documentation ¶
Index ¶
- func GenerateWorkData() (string, error)
- type ProofOfWork
- func (pow *ProofOfWork) HasDoneWork() bool
- func (pow *ProofOfWork) IsValid() bool
- func (pow *ProofOfWork) MarshalJSON() ([]byte, error)
- func (pow *ProofOfWork) String() string
- func (pow *ProofOfWork) UnmarshalJSON(b []byte) error
- func (pow *ProofOfWork) Work(cores int)
- func (pow *ProofOfWork) WorkMulticore()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateWorkData ¶
GenerateWorkData generates random work
Types ¶
type ProofOfWork ¶
type ProofOfWork struct { Bits int `json:"bits"` Data string `json:"data"` Proof uint64 `json:"proof,omitempty"` }
ProofOfWork represents a proof-of-work which either can be completed or not
func New ¶
func New(bits int, data string, proof uint64) *ProofOfWork
New generates a new ProofOfWork structure.
func NewFromString ¶
func NewFromString(s string) (*ProofOfWork, error)
NewFromString generates a proof-of-work based on the given string
func NewWithoutProof ¶
func NewWithoutProof(bits int, data string) *ProofOfWork
NewWithoutProof returns a new proof-of-work without actual proof (needs to be worked on)
func (*ProofOfWork) HasDoneWork ¶
func (pow *ProofOfWork) HasDoneWork() bool
HasDoneWork returns true if this instance already has done proof-of-work
func (*ProofOfWork) IsValid ¶
func (pow *ProofOfWork) IsValid() bool
IsValid returns true when the given work can be validated against the proof
func (*ProofOfWork) MarshalJSON ¶
func (pow *ProofOfWork) MarshalJSON() ([]byte, error)
MarshalJSON marshals a pow into bytes
func (*ProofOfWork) String ¶
func (pow *ProofOfWork) String() string
Return a representation of proof-of-work
func (*ProofOfWork) UnmarshalJSON ¶
func (pow *ProofOfWork) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals bytes into a pow
func (*ProofOfWork) Work ¶
func (pow *ProofOfWork) Work(cores int)
Work actually does the proof-of-work on the given amount of cores
func (*ProofOfWork) WorkMulticore ¶
func (pow *ProofOfWork) WorkMulticore()
WorkMulticore will work on all cores possible