types

package
v0.6.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Account transactions
	TxTypeSend = byte(0x01)
	TxTypeApp  = byte(0x02)
	TxNameSend = "send"
	TxNameApp  = "app"
)

Types of Tx implementations

Variables

This section is empty.

Functions

func AccountKey added in v0.6.2

func AccountKey(addr []byte) []byte

func LegibleBytes added in v0.6.2

func LegibleBytes(data []byte) string

func SetAccount added in v0.6.2

func SetAccount(store KVStore, addr []byte, acc *Account)

func SignTx added in v0.6.2

func SignTx(chainID string, tx *SendTx, accs ...PrivAccount)

func TxID added in v0.6.2

func TxID(chainID string, tx Tx) []byte

Types

type Account

type Account struct {
	PubKey   crypto.PubKey `json:"pub_key"` // May be nil, if not known.
	Sequence int           `json:"sequence"`
	Balance  Coins         `json:"coins"`
}

func GetAccount added in v0.6.2

func GetAccount(store KVStore, addr []byte) *Account

func (*Account) Copy added in v0.6.2

func (acc *Account) Copy() *Account

func (*Account) String added in v0.6.2

func (acc *Account) String() string

type AccountGetter added in v0.6.2

type AccountGetter interface {
	GetAccount(addr []byte) *Account
}

type AccountGetterSetter added in v0.6.2

type AccountGetterSetter interface {
	GetAccount(addr []byte) *Account
	SetAccount(addr []byte, acc *Account)
}

type AccountSetter added in v0.6.2

type AccountSetter interface {
	SetAccount(addr []byte, acc *Account)
}

type AppTx added in v0.6.2

type AppTx struct {
	Gas   int64           `json:"gas"`   // Gas
	Fee   Coin            `json:"fee"`   // Fee
	Name  string          `json:"type"`  // Which plugin
	Input TxInput         `json:"input"` // Hmmm do we want coins?
	Data  json.RawMessage `json:"data"`
}

func (*AppTx) AssertIsTx added in v0.6.2

func (_ *AppTx) AssertIsTx()

func (*AppTx) SetSignature added in v0.6.2

func (tx *AppTx) SetSignature(sig crypto.Signature) bool

func (*AppTx) SignBytes added in v0.6.2

func (tx *AppTx) SignBytes(chainID string) []byte

func (*AppTx) String added in v0.6.2

func (tx *AppTx) String() string

type CallContext added in v0.6.2

type CallContext struct {
	CallerAddress []byte   // Caller's Address (hash of PubKey)
	CallerAccount *Account // Caller's Account, w/ fee & TxInputs deducted
	Coins         Coins    // The coins that the caller wishes to spend, excluding fees
}

func NewCallContext added in v0.6.2

func NewCallContext(callerAddress []byte, callerAccount *Account, coins Coins) CallContext

type Coin

type Coin struct {
	Denom  string `json:"denom"`
	Amount int64  `json:"amount"`
}

func ParseCoin

func ParseCoin(str string) (Coin, error)

func (Coin) String

func (coin Coin) String() string

type Coins

type Coins []Coin

func ParseCoins

func ParseCoins(str string) (Coins, error)

func (Coins) IsEqual

func (coinsA Coins) IsEqual(coinsB Coins) bool

func (Coins) IsGTE

func (coinsA Coins) IsGTE(coinsB Coins) bool

func (Coins) IsNonnegative added in v0.6.2

func (coins Coins) IsNonnegative() bool

func (Coins) IsPositive

func (coins Coins) IsPositive() bool

func (Coins) IsValid

func (coins Coins) IsValid() bool

Must be sorted, and not have 0 amounts

func (Coins) IsZero

func (coins Coins) IsZero() bool

func (Coins) Len

func (c Coins) Len() int

func (Coins) Less

func (c Coins) Less(i, j int) bool

func (Coins) Minus

func (coinsA Coins) Minus(coinsB Coins) Coins

func (Coins) Negative

func (coins Coins) Negative() Coins

func (Coins) Plus

func (coinsA Coins) Plus(coinsB Coins) Coins

TODO: handle empty coins! Currently appends an empty coin ...

func (Coins) Sort

func (c Coins) Sort()

func (Coins) String

func (coins Coins) String() string

func (Coins) Swap

func (c Coins) Swap(i, j int)

type KVCache added in v0.6.2

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

A Cache that enforces deterministic sync order.

func NewKVCache added in v0.6.2

func NewKVCache(store KVStore) *KVCache

NOTE: If store is nil, creates a new MemKVStore

func (*KVCache) ClearLogLines added in v0.6.2

func (kvc *KVCache) ClearLogLines()

func (*KVCache) Get added in v0.6.2

func (kvc *KVCache) Get(key []byte) (value []byte)

func (*KVCache) GetLogLines added in v0.6.2

func (kvc *KVCache) GetLogLines() []string

func (*KVCache) Reset added in v0.6.2

func (kvc *KVCache) Reset() *KVCache

func (*KVCache) Set added in v0.6.2

func (kvc *KVCache) Set(key []byte, value []byte)

func (*KVCache) SetLogging added in v0.6.2

func (kvc *KVCache) SetLogging()

func (*KVCache) Sync added in v0.6.2

func (kvc *KVCache) Sync()

Update the store with the values from the cache

type KVStore

type KVStore interface {
	Set(key, value []byte)
	Get(key []byte) (value []byte)
}

type MemKVStore added in v0.6.2

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

func NewMemKVStore added in v0.6.2

func NewMemKVStore() *MemKVStore

func (*MemKVStore) Get added in v0.6.2

func (mkv *MemKVStore) Get(key []byte) (value []byte)

func (*MemKVStore) Set added in v0.6.2

func (mkv *MemKVStore) Set(key []byte, value []byte)

type Plugin added in v0.6.2

type Plugin interface {

	// Name of this plugin, should be short.
	Name() string

	// Run a transaction from ABCI DeliverTx
	RunTx(store KVStore, ctx CallContext, txBytes []byte) (res abci.Result)

	// Other ABCI message handlers
	SetOption(store KVStore, key, value string) (log string)
	InitChain(store KVStore, vals []*abci.Validator)
	BeginBlock(store KVStore, hash []byte, header *abci.Header)
	EndBlock(store KVStore, height uint64) abci.ResponseEndBlock
}

type Plugins added in v0.6.2

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

func NewPlugins added in v0.6.2

func NewPlugins() *Plugins

func (*Plugins) GetByName added in v0.6.2

func (pgz *Plugins) GetByName(name string) Plugin

func (*Plugins) GetList added in v0.6.2

func (pgz *Plugins) GetList() []Plugin

func (*Plugins) RegisterPlugin added in v0.6.2

func (pgz *Plugins) RegisterPlugin(plugin Plugin)

type PrivAccount added in v0.6.2

type PrivAccount struct {
	crypto.PrivKey
	Account
}

func MakeAcc added in v0.6.2

func MakeAcc(secret string) PrivAccount

func PrivAccountFromSecret added in v0.6.2

func PrivAccountFromSecret(secret string) PrivAccount

Creates a PrivAccount from secret. The amount is not set.

func RandAccounts added in v0.6.2

func RandAccounts(num int, minAmount int64, maxAmount int64) []PrivAccount

Make `num` random accounts

type SendTx added in v0.6.2

type SendTx struct {
	Gas     int64      `json:"gas"` // Gas
	Fee     Coin       `json:"fee"` // Fee
	Inputs  []TxInput  `json:"inputs"`
	Outputs []TxOutput `json:"outputs"`
}

func MakeSendTx added in v0.6.2

func MakeSendTx(seq int, accOut PrivAccount, accsIn ...PrivAccount) *SendTx

func (*SendTx) AssertIsTx added in v0.6.2

func (_ *SendTx) AssertIsTx()

func (*SendTx) SetSignature added in v0.6.2

func (tx *SendTx) SetSignature(addr []byte, sig crypto.Signature) bool

func (*SendTx) SignBytes added in v0.6.2

func (tx *SendTx) SignBytes(chainID string) []byte

func (*SendTx) String added in v0.6.2

func (tx *SendTx) String() string

type Tx

type Tx interface {
	AssertIsTx()
	SignBytes(chainID string) []byte
}

Tx (Transaction) is an atomic operation on the ledger state.

Account Types:

  • SendTx Send coins to address
  • AppTx Send a msg to a contract that runs in the vm

type TxInput added in v0.6.2

type TxInput struct {
	Address   data.Bytes       `json:"address"`   // Hash of the PubKey
	Coins     Coins            `json:"coins"`     //
	Sequence  int              `json:"sequence"`  // Must be 1 greater than the last committed TxInput
	Signature crypto.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx
	PubKey    crypto.PubKey    `json:"pub_key"`   // Is present iff Sequence == 0
}

func Accs2TxInputs added in v0.6.2

func Accs2TxInputs(seq int, accs ...PrivAccount) []TxInput

func NewTxInput added in v0.6.2

func NewTxInput(pubKey crypto.PubKey, coins Coins, sequence int) TxInput

func (TxInput) String added in v0.6.2

func (txIn TxInput) String() string

func (TxInput) ValidateBasic added in v0.6.2

func (txIn TxInput) ValidateBasic() abci.Result

type TxOutput added in v0.6.2

type TxOutput struct {
	Address data.Bytes `json:"address"` // Hash of the PubKey
	Coins   Coins      `json:"coins"`   //
}

func Accs2TxOutputs added in v0.6.2

func Accs2TxOutputs(accs ...PrivAccount) []TxOutput

turn a list of accounts into basic list of transaction outputs

func (TxOutput) ChainAndAddress added in v0.6.2

func (txOut TxOutput) ChainAndAddress() ([]byte, []byte, abci.Result)

An output destined for another chain may be formatted as `chainID/address`. ChainAndAddress returns the chainID prefix and the address. If there is no chainID prefix, the first returned value is nil.

func (TxOutput) String added in v0.6.2

func (txOut TxOutput) String() string

func (TxOutput) ValidateBasic added in v0.6.2

func (txOut TxOutput) ValidateBasic() abci.Result

type TxS added in v0.6.2

type TxS struct {
	Tx `json:"unwrap"`
}

TxS add json serialization to Tx

func (TxS) MarshalJSON added in v0.6.2

func (p TxS) MarshalJSON() ([]byte, error)

func (*TxS) UnmarshalJSON added in v0.6.2

func (p *TxS) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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