v2

package
v0.0.0-...-b10619e Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCancelled = errors.New("canceled")
	ErrDone      = errors.New("done")
)

errors returned by the PoW

Functions

func Score

func Score(msg []byte) uint64

Score returns the PoW score of msg.

Types

type Worker

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

The Worker performs the PoW.

func New

func New(numWorkers ...int) *Worker

New creates a new PoW Worker. The optional numWorkers specifies how many go routines should be used to perform the PoW.

func (*Worker) Mine

func (w *Worker) Mine(ctx context.Context, data []byte, targetScore uint64) (uint64, error)

Mine performs the PoW for data. It returns a nonce that appended to data results in a PoW score of at least targetScore. The computation can be canceled anytime using ctx.

Jump to

Keyboard shortcuts

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