pow

package
v0.23.0-iris Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInvalidCount

func ErrInvalidCount(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrInvalidDifficulty

func ErrInvalidDifficulty(codespace sdk.CodespaceType, msg string) sdk.Error

nolint

func ErrInvalidProof

func ErrInvalidProof(codespace sdk.CodespaceType, msg string) sdk.Error

func ErrNonexistentCount

func ErrNonexistentCount(codespace sdk.CodespaceType) sdk.Error

func ErrNonexistentDifficulty

func ErrNonexistentDifficulty(codespace sdk.CodespaceType) sdk.Error

func ErrNonexistentReward

func ErrNonexistentReward(codespace sdk.CodespaceType) sdk.Error

func ErrNotBelowTarget

func ErrNotBelowTarget(codespace sdk.CodespaceType, msg string) sdk.Error

func InitGenesis added in v0.16.0

func InitGenesis(ctx sdk.Context, k Keeper, genesis Genesis) error

InitGenesis for the POW module

func RegisterWire added in v0.16.0

func RegisterWire(cdc *wire.Codec)

Register concrete types on wire codec

Types

type CodeType

type CodeType = sdk.CodeType

TODO remove, seems hacky

const (
	DefaultCodespace          sdk.CodespaceType = 5
	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
)

POW errors reserve 200 ~ 299

type Config added in v0.16.0

type Config struct {
	Denomination string
	Reward       int64
}

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

func NewConfig added in v0.16.0

func NewConfig(denomination string, reward int64) Config

type Genesis added in v0.16.0

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

genesis info must specify starting difficulty and starting count

func WriteGenesis added in v0.16.0

func WriteGenesis(ctx sdk.Context, k Keeper) Genesis

WriteGenesis for the PoW module

type Keeper

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

POW Keeper

func NewKeeper

func NewKeeper(key sdk.StoreKey, config Config, ck bank.Keeper, codespace sdk.CodespaceType) Keeper

func (Keeper) ApplyValid

func (k Keeper) ApplyValid(ctx sdk.Context, sender sdk.AccAddress, newDifficulty uint64, newCount uint64) sdk.Error

Add some coins for a POW well done

func (Keeper) CheckValid

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

Is the keeper state valid?

func (Keeper) GetLastCount

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

get the last count

func (Keeper) GetLastDifficulty

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

get the last mining difficulty

func (Keeper) Handler

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

POW handler

func (Keeper) SetLastCount

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

set the last count

func (Keeper) SetLastDifficulty

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

set the last mining difficulty

type MsgMine added in v0.16.0

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

MsgMine - mine some coins with PoW

func GenerateMsgMine added in v0.16.0

func GenerateMsgMine(sender sdk.AccAddress, count uint64, difficulty uint64) MsgMine

generate the mine message

func NewMsgMine added in v0.16.0

func NewMsgMine(sender sdk.AccAddress, difficulty uint64, count uint64, nonce uint64, proof []byte) MsgMine

NewMsgMine - construct mine message

func (MsgMine) GetSignBytes added in v0.16.0

func (msg MsgMine) GetSignBytes() []byte

get the mine message sign bytes

func (MsgMine) GetSigners added in v0.16.0

func (msg MsgMine) GetSigners() []sdk.AccAddress

func (MsgMine) String added in v0.16.0

func (msg MsgMine) String() string

func (MsgMine) Type added in v0.16.0

func (msg MsgMine) Type() string

nolint

func (MsgMine) ValidateBasic added in v0.16.0

func (msg MsgMine) ValidateBasic() sdk.Error

validate the mine message

Directories

Path Synopsis
client
cli

Jump to

Keyboard shortcuts

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