action

package
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: Apache-2.0 Imports: 14 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 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

This section is empty.

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    string `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, value string) *Amount

New Amount creates a new amount account object

func (Amount) IsValid

func (a Amount) IsValid(ctx *Context) 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(ctx *Context) 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 ApplyValidator added in v0.10.4

type ApplyValidator struct {
	Address          Address
	Stake            Amount
	NodeName         string
	ValidatorAddress Address
	ValidatorPubKey  keys.PublicKey
	Purge            bool
}

func (ApplyValidator) Bytes added in v0.10.4

func (apply ApplyValidator) Bytes() []byte

func (ApplyValidator) Signers added in v0.10.4

func (apply ApplyValidator) Signers() []Address

func (ApplyValidator) Tags added in v0.10.4

func (apply ApplyValidator) Tags() common.KVPairs

func (ApplyValidator) Type added in v0.10.4

func (apply ApplyValidator) Type() Type

type Balance

type Balance = balance.Balance

Balance an action package over Balance in data/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
	Validators *identity.ValidatorStore
	Logger     *log.Logger
}

func NewContext

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

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, memo string, 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
	APPLYVALIDATOR
)

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