counter

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameCounter = "cntr"
	ByteTx      = 0x2F //TODO What does this byte represent should use typebytes probably
	TypeTx      = NameCounter + "/count"
)

register the tx type with it's validation logic make sure to use the name of the handler as the prefix in the tx type, so it gets routed properly

Variables

This section is empty.

Functions

func ErrDecoding

func ErrDecoding() error

ErrDecoding - This is just a helper function to return a generic "internal error"

func ErrInvalidCounter

func ErrInvalidCounter() error

ErrInvalidCounter - custom error class

func IsInvalidCounterErr

func IsInvalidCounterErr(err error) bool

IsInvalidCounterErr - custom error class check

func NewHandler

func NewHandler(feeDenom string) sdk.Handler

NewHandler returns a new counter transaction processing handler

func NewTx

func NewTx(valid bool, fee coin.Coins) sdk.Tx

NewTx - return a new counter transaction struct wrapped as a basecoin transaction

func SaveState

func SaveState(store state.SimpleDB, state State) error

SaveState - save the counter state to the provided store

func StateKey

func StateKey() []byte

StateKey - store key for the counter state

func StoreActor

func StoreActor() sdk.Actor

StoreActor - return the basecoin actor for the account

Types

type Handler

type Handler struct {
	stack.PassInitState
	stack.PassInitValidate
}

Handler the counter transaction processing handler

func (Handler) AssertDispatcher

func (Handler) AssertDispatcher()

AssertDispatcher - placeholder to satisfy XXX

func (Handler) CheckTx

func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error)

CheckTx checks if the tx is properly structured

func (Handler) DeliverTx

func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, dispatch sdk.Deliver) (res sdk.DeliverResult, err error)

DeliverTx executes the tx if valid

func (Handler) Name

func (Handler) Name() string

Name - return counter namespace

type State

type State struct {
	Counter   int        `json:"counter"`
	TotalFees coin.Coins `json:"total_fees"`
}

State - state of the counter applicaton

func LoadState

func LoadState(store state.SimpleDB) (state State, err error)

LoadState - retrieve the counter state from the store

type Tx

type Tx struct {
	Valid bool       `json:"valid"`
	Fee   coin.Coins `json:"fee"`
}

Tx - struct for all counter transactions

func (Tx) ValidateBasic

func (c Tx) ValidateBasic() error

ValidateBasic just makes sure the Fee is a valid, non-negative value

func (Tx) Wrap

func (c Tx) Wrap() sdk.Tx

Wrap - Wrap a Tx as a Basecoin Tx, used to satisfy the XXX interface

Jump to

Keyboard shortcuts

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