action

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingData      = errors.New("missing data for send tx")
	ErrWrongTxType      = errors.New("wrong tx type")
	ErrInvalidAmount    = errors.New("invalid amount")
	ErrInvalidPubkey    = errors.New("invalid pubkey")
	ErrUnmatchSigner    = errors.New("unmatch signers")
	ErrInvalidSignature = errors.New("invalid signatures")
	ErrInvalidFee       = errors.New("invalid fees")
)

Functions

This section is empty.

Types

type Address

type Address = keys.Address

type Amount

type Amount struct {
	Currency string `json:"currency"`
	Value    string `json:"value"`
}

func (Amount) IsValid

func (a Amount) IsValid(ctx *Context) bool

func (Amount) String

func (a Amount) String() string

func (Amount) ToCoin

func (a Amount) ToCoin(ctx *Context) balance.Coin

type Balance

type Balance = balance.Balance

type BaseTx

type BaseTx struct {
	Data       Msg         `json:"tx_data"`
	Fee        Fee         `json:"fee"`
	Signatures []Signature `json:"signatures"`
	Memo       string      `json:"memo"`
}

func (*BaseTx) Bytes

func (t *BaseTx) Bytes() []byte

func (*BaseTx) Sign

func (t *BaseTx) Sign(ctx *Context) error

func (*BaseTx) SignWithAddress

func (t *BaseTx) SignWithAddress(ctx *Context, address Address) error

type Context

type Context struct {
	Router     Router
	Accounts   accounts.Wallet
	Balances   *balance.Store
	Currencies *balance.CurrencyList
	Logger     *log.Logger
}

func NewContext

func NewContext(r Router, wallet accounts.Wallet, balances *balance.Store, currencies *balance.CurrencyList, logger *log.Logger) *Context

func (*Context) EnableSend

func (ctx *Context) EnableSend() *Context

enable sendTx

type Fee

type Fee struct {
	Price Amount
	Gas   int64
}

type Msg

type Msg interface {
	// return the necessary signers for the message, should have consistent order across the network
	Signers() []Address

	Type() Type

	Bytes() []byte
}

type Response

type Response struct {
	Data      []byte
	Log       string
	Info      string
	GasWanted int64
	GasUsed   int64
	Tags      []common.KVPair
}

type Router

type Router interface {
	AddHandler(Type, Tx) error
	Handler(Msg) Tx
}

Router interface supplies functionality to add a handler function and Handle a request.

func NewRouter

func NewRouter(name string) Router

NewRouter creates a new router object with given name.

type Send

type Send struct {
	From   Address
	To     Address
	Amount Amount
}

func (Send) Bytes

func (s Send) Bytes() []byte

func (Send) Signers

func (s Send) Signers() []Address

func (Send) Tags

func (s Send) Tags() common.KVPairs

func (Send) Type

func (s Send) Type() Type

type Signature

type Signature struct {
	Signer keys.PublicKey
	Signed []byte
}

func (Signature) Verify

func (s Signature) Verify(msg []byte) bool

type Tx

type Tx interface {
	//it should be able to validate a tx by itself, non-valid tx will be reject by the node directly
	//without going to node process
	Validate(ctx *Context, msg Msg, fee Fee, signatures []Signature) (bool, error)

	//check tx on the first node who receives it, if process check failed, the tx will not be broadcast
	//could store a version of checked value in storage, but not implemented now
	ProcessCheck(ctx *Context, msg Msg, fee Fee) (bool, Response)

	//deliver tx on the chain by changing the storage values, which should only be committed at Application
	//commit stage
	ProcessDeliver(ctx *Context, msg Msg, fee Fee) (bool, Response)

	//process the charge of fees
	ProcessFee(ctx *Context, fee Fee) (bool, Response)
}

type Type

type Type int
const (
	SEND Type = iota
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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