proofofwork

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateWorkData

func GenerateWorkData() (string, error)

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

Jump to

Keyboard shortcuts

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