pow

package
v0.0.0-...-10088a8 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

pow package is responsible for proof of work calculation/verification for an object transmitted over the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateTarget

func CalculateTarget(PayloadLength, TTL, NonceTrialsPerByte,
	PayloadLengthExtraBytes int) uint64

CalculateTarget calculates the target POW value. PayloadLength includes the full length of the payload (inluding the width of the initial nonce field). TTL is the time to live (in seconds). Information about NonceTrialsPerByte and PayloadLengthExtraBytes can be found at: https://bitmessage.org/wiki/Proof_of_work

func Check

func Check(objectData []byte, PayloadLengthExtraBytes, NonceTrialsPerByte int) bool

Check checks if the POW that was done for an object is sufficient.

func DoOpenCL

func DoOpenCL(target uint64, initialHash []byte) uint64

DoGPU does the POW on an OpenCL supported device and returns the nonce value.

func DoParallel

func DoParallel(target uint64, initialHash []byte, parallelCount int) uint64

DoParallel does the POW using cpuCount number of goroutines and returns the nonce value. TODO: Optimize parallel and make it stable. Performance is very volatile at the moment.

func DoSequential

func DoSequential(target uint64, initialHash []byte) uint64

DoSequential does the POW sequentially and returns the nonce value.

Types

type Do

type Do func(target uint64, initialHash []byte) uint64

Do is the signature of a POW implementation that returns a nonce value.

Jump to

Keyboard shortcuts

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