hashcash

package
v0.0.0-...-2f6ec98 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stamp

type Stamp struct {
	Version    int    `json:"version"`
	ZerosCount int    `json:"zerosCount"`
	Date       int64  `json:"date"`
	Resource   string `json:"resource"`
	Rand       string `json:"rand"`
	Counter    int    `json:"counter"`
}

Stamp - represents hashcash stamp

func HashToStamp

func HashToStamp(hash string) (Stamp, error)

HashToStamp converts hashstring to stamp

func (Stamp) ComputeHashcash

func (s Stamp) ComputeHashcash(maxIterations int) (Stamp, error)

ComputeHashcash - calculates correct hashcash by bruteforce until the resulting hash satisfies the condition of IsHashCorrect maxIterations to prevent endless computing (0 or -1 to disable it)

func (*Stamp) IsHashSolved

func (s *Stamp) IsHashSolved() bool

IsHashCorrect - checks that hash has leading <zerosCount> zeros

func (Stamp) ToString

func (s Stamp) ToString() string

ToString - converts stamp to hash string

func (*Stamp) ValidStamp

func (p *Stamp) ValidStamp(ctx context.Context, stampForValidation Stamp, repo repository.Repository) bool

ValidStamp - checks if the stamp is valid

Jump to

Keyboard shortcuts

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