Documentation ¶
Overview ¶
Package pow is a simple "proof of work" interface.
It's based on a revers SHA512_224 function with a dynamic difficulty. New generated "POW" are saved in memeory tree using "github.com/google/btree". Challenge request contains an ID, a target, the needed difficulty and an expiration time.
The package save issued challenge requests and delete it when validate. That way the POW can't be use more than ones. Any request to the tree are piped to a channel to permit secured concurent access.
Embedded JSON generation, resolution and check for simple communication.
It is licence under "BSD 3-Clause License"
Index ¶
- func Check(resp *challenger.Response) bool
- func CheckJSON(input []byte) bool
- func GetChallenge(difficulty uint16, expirationTime time.Time) (*request.Challenge, error)
- func GetChallengeAsJSON(difficulty uint16, expirationTime time.Time) ([]byte, error)
- func NewResolveLimits(dur time.Duration, trys uint64, nbBytes int) *challenger.ResolveLimits
- func Resolve(challengeRequest *request.Challenge, limits *challenger.ResolveLimits) (*challenger.Response, error)
- func ResolveAsJSON(input []byte, limits *challenger.ResolveLimits) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(resp *challenger.Response) bool
Check give an easy way to just check if the response. It check the resulting hash is correct and the chalenge is part of the actives challenges list.
func CheckJSON ¶
CheckJSON do the same as check but take a slice of byte as argument. The slice must represent a challenger.Response as JSON.
func GetChallenge ¶
GetChallenge return a challenge object or an error
func GetChallengeAsJSON ¶
GetChallengeAsJSON is analog to GetChallenge Exept it returns a slice of byte representing the element as JSON
func NewResolveLimits ¶
func NewResolveLimits(dur time.Duration, trys uint64, nbBytes int) *challenger.ResolveLimits
NewResolveLimits build a new resolver limitations
func Resolve ¶
func Resolve(challengeRequest *request.Challenge, limits *challenger.ResolveLimits) (*challenger.Response, error)
Resolve true to resolve the challenge. It returns the solution or an error.
func ResolveAsJSON ¶
func ResolveAsJSON(input []byte, limits *challenger.ResolveLimits) ([]byte, error)
ResolveAsJSON is analog to Resolve Exept it returns a slice of byte representing the element as JSON
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package common contain the common functions of the challenger and the requester.
|
Package common contain the common functions of the challenger and the requester. |