common

package
v0.0.0-...-83390d5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package common contain the common functions of the challenger and the requester.

This package should'nt be used by users. This functions should be colled from the pow package witch calls those functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteToBits

func ByteToBits(x byte) (ret [8]byte)

ByteToBits convert a byte into a slice of bits

func CheckLastByteEqual

func CheckLastByteEqual(respByte, serverComputing []byte, diff uint16) bool

func ConcatIDAndTestSolution

func ConcatIDAndTestSolution(id, try []byte) []byte

ConcatIDAndTestSolution make a string containing the challenge ID and the try. It make the try unique for any challenge

func EqualByte

func EqualByte(b1, b2 byte, diff uint16) bool

EqualByte is supposed to be called on the last byte of the check

func GetDiffAsByte

func GetDiffAsByte(diff uint16) uint

GetDiffAsByte returns the numbers of bytes needed to hold the this numbers of bits.

func Hash

func Hash(t *TryStruct) ([]byte, error)

Hash do the hash function

func IDToSlice

func IDToSlice(id uint64) []byte

IDToSlice is a simple function witch get an integer and return a slice of bytes.

func Try

func Try(t *TryStruct, tryChan chan *TryResponse)

Try try the given solution and return the result into the given channel

Types

type TryResponse

type TryResponse struct {
	Found    bool   // Been found
	Solution []byte // Save the solution
}

TryResponse represent the response of the try.

type TryStruct

type TryStruct struct {
	N, Salt, Target []byte
	ResponseChan    chan *TryResponse

	Challenge *request.Challenge
}

TryStruct is a struct used to define what paramiters must be used for this try.

Jump to

Keyboard shortcuts

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