pow

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler handles PoW requests of the node and tunnels them to powsrv.io or uses local PoW if no API key was specified or the connection failed.

func New

func New(log *logger.Logger, targetScore float64, refreshTipsInterval time.Duration, powsrvAPIKey string, powsrvInitCooldown time.Duration) *Handler

New creates a new PoW handler instance. If the given powsrv.io API key is not empty, powsrv.io will be used to do proof-of-work.

func (*Handler) Close

func (h *Handler) Close()

Close closes the PoW handler

func (*Handler) DoPoW

func (h *Handler) DoPoW(msg *iotago.Message, shutdownSignal <-chan struct{}, parallelism int, refreshTipsFunc ...RefreshTipsFunc) (err error)

DoPoW does the proof-of-work required to hit the target score configured on this Handler. The given iota.Message's nonce is automatically updated. If a powsrv.io key was provided, then powsrv.io is used to commence the proof-of-work.

func (*Handler) GetPoWType

func (h *Handler) GetPoWType() string

GetPoWType returns the fastest available PoW type which gets used for PoW requests

type RefreshTipsFunc added in v1.0.0

type RefreshTipsFunc = func() (tips hornet.MessageIDs, err error)

RefreshTipsFunc refreshes tips of the message if PoW takes longer than a configured duration.

Jump to

Keyboard shortcuts

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