action

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingData      = errors.New("missing data for tx")
	ErrUnserializable   = errors.New("unserializable 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")
	ErrNotEnoughFund    = errors.New("not enough fund")
)

Functions

func ValidateBasic added in v0.10.8

func ValidateBasic(data []byte, signerAddr []Address, signatures []Signature) (bool, error)

Types

type Address

type Address = keys.Address

Address an action package over Address in data/keys package

type Amount

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

Amount is an easily serializable representation of coin. Nodes can create coin from the Amount object received over the network

func NewAmount added in v0.10.4

func NewAmount(currency string, amount balance.Amount) *Amount

New Amount creates a new amount account object

func (Amount) IsValid

func (a Amount) IsValid(list *balance.CurrencyList) bool

IsValid checks the validity of the currency and the amount string in the account object, which may be received over a network.

func (Amount) String

func (a Amount) String() string

String returns a string representation of the Amount object.

func (Amount) ToCoin

func (a Amount) ToCoin(list *balance.CurrencyList) balance.Coin

ToCoin converts an easier to transport Amount object to a Coin object in Oneledger protocol. It takes the action context to determine the currency from which to create the coin.

type Balance

type Balance = balance.Balance

Balance an action package over Balance in data/balance

type Context

type Context struct {
	Router     Router
	Header     *abci.Header
	Accounts   accounts.Wallet
	Balances   *balance.Store
	Domains    *ons.DomainStore
	Currencies *balance.CurrencyList
	Validators *identity.ValidatorStore
	Logger     *log.Logger
}

func NewContext

func NewContext(r Router, header *abci.Header, wallet accounts.Wallet, balances *balance.Store, currencies *balance.CurrencyList,
	validators *identity.ValidatorStore, domains *ons.DomainStore, logger *log.Logger) *Context

type Fee

type Fee struct {
	Price Amount `json:"price"`
	Gas   int64  `json:"gas"`
}

type Msg

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

	Type() Type

	Tags() common.KVPairs

	Marshal() ([]byte, error)

	Unmarshal([]byte) error
}

type MsgData added in v0.10.8

type MsgData []byte

type RawTx added in v0.10.8

type RawTx struct {
	Type Type    `json:"tx_type"`
	Data MsgData `json:"tx_data"`
	Fee  Fee     `json:"fee"`
	Memo string  `json:"memo"`
}

func (*RawTx) RawBytes added in v0.10.8

func (t *RawTx) RawBytes() []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(Type) 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 Signature

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

func (Signature) Verify

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

type SignedTx added in v0.10.8

type SignedTx struct {
	RawTx
	Signatures []Signature `json:"signatures"`
}

func (*SignedTx) SignedBytes added in v0.10.8

func (t *SignedTx) SignedBytes() []byte

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, signedTx SignedTx) (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, tx RawTx) (bool, Response)

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

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

type Type

type Type int
const (
	SEND Type = iota
	APPLYVALIDATOR

	//ons related transaction
	DOMAIN_CREATE
	DOMAIN_UPDATE
	DOMAIN_SELL
	DOMAIN_PURCHASE
	DOMAIN_SEND
)

func (Type) String

func (t Type) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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