pow

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInvalidCount

func ErrInvalidCount(msg string) sdk.Error

func ErrInvalidDifficulty

func ErrInvalidDifficulty(msg string) sdk.Error

func ErrInvalidProof

func ErrInvalidProof(msg string) sdk.Error

func ErrNonexistentCount

func ErrNonexistentCount() sdk.Error

func ErrNonexistentDifficulty

func ErrNonexistentDifficulty() sdk.Error

func ErrNonexistentReward

func ErrNonexistentReward() sdk.Error

func ErrNotBelowTarget

func ErrNotBelowTarget(msg string) sdk.Error

Types

type CodeType

type CodeType = sdk.CodeType
const (
	CodeInvalidDifficulty     CodeType = 201
	CodeNonexistentDifficulty CodeType = 202
	CodeNonexistentReward     CodeType = 203
	CodeNonexistentCount      CodeType = 204
	CodeInvalidProof          CodeType = 205
	CodeNotBelowTarget        CodeType = 206
	CodeInvalidCount          CodeType = 207
	CodeUnknownRequest        CodeType = sdk.CodeUnknownRequest
)

type Keeper

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

func NewKeeper

func NewKeeper(key sdk.StoreKey, config PowConfig, ck bank.CoinKeeper) Keeper

func (Keeper) ApplyValid

func (pk Keeper) ApplyValid(ctx sdk.Context, sender sdk.Address, newDifficulty uint64, newCount uint64) sdk.Error

func (Keeper) CheckValid

func (pk Keeper) CheckValid(ctx sdk.Context, difficulty uint64, count uint64) (uint64, uint64, sdk.Error)

func (Keeper) GetLastCount

func (pk Keeper) GetLastCount(ctx sdk.Context) (uint64, error)

func (Keeper) GetLastDifficulty

func (pk Keeper) GetLastDifficulty(ctx sdk.Context) (uint64, error)

func (Keeper) Handler

func (pk Keeper) Handler(ctx sdk.Context, msg sdk.Msg) sdk.Result

func (Keeper) InitGenesis

func (pk Keeper) InitGenesis(ctx sdk.Context, genesis PowGenesis) error

func (Keeper) SetLastCount

func (pk Keeper) SetLastCount(ctx sdk.Context, count uint64)

func (Keeper) SetLastDifficulty

func (pk Keeper) SetLastDifficulty(ctx sdk.Context, diff uint64)

type MineMsg

type MineMsg struct {
	Sender     sdk.Address `json:"sender"`
	Difficulty uint64      `json:"difficulty"`
	Count      uint64      `json:"count"`
	Nonce      uint64      `json:"nonce"`
	Proof      []byte      `json:"proof"`
}

MineMsg - mine some coins with PoW

func GenerateMineMsg

func GenerateMineMsg(sender sdk.Address, count uint64, difficulty uint64) MineMsg

func NewMineMsg

func NewMineMsg(sender sdk.Address, difficulty uint64, count uint64, nonce uint64, proof []byte) MineMsg

NewMineMsg - construct mine message

func (MineMsg) Get

func (msg MineMsg) Get(key interface{}) (value interface{})

func (MineMsg) GetSignBytes

func (msg MineMsg) GetSignBytes() []byte

func (MineMsg) GetSigners

func (msg MineMsg) GetSigners() []sdk.Address

func (MineMsg) String

func (msg MineMsg) String() string

func (MineMsg) Type

func (msg MineMsg) Type() string

func (MineMsg) ValidateBasic

func (msg MineMsg) ValidateBasic() sdk.Error

type PowConfig

type PowConfig struct {
	Denomination string
	Reward       int64
}

module users must specify coin denomination and reward (constant) per PoW solution

func NewPowConfig

func NewPowConfig(denomination string, reward int64) PowConfig

type PowGenesis

type PowGenesis struct {
	Difficulty uint64 `json:"difficulty"`
	Count      uint64 `json:"count"`
}

genesis info must specify starting difficulty and starting count

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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