dmccoin

package
v0.0.0-...-0ce3ae6 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Account transactions
	TxTypeUTXO = byte(0x01)
	TxTypeApp  = byte(0x02)
	TxTypeDMC  = byte(0x03)
	TxNameUTXO = "utxo"
	TxNameApp  = "app"
	TxNameDMC  = "dmc"
)

Types of Tx implementations

Variables

This section is empty.

Functions

func AccountKey

func AccountKey(addr []byte) []byte

func ExecTx

func ExecTx(state *State, tx Tx, isCheckTx bool, evc events.Fireable, height int64) abci.ResponseDeliverTx

If the tx is invalid, a TMSP error will be returned.

func InitKVStore

func InitKVStore(app *DMCCoinApplication)

InitKVStore initializes the kvstore app with some data, which allows tests to pass and is fine as long as you don't make any tx that modify the validator state

func LegibleBytes

func LegibleBytes(data []byte) string

func RandVal

func RandVal(i int) types.Validator

RandVal creates one random validator, with a key derived from the input value

func RandVals

func RandVals(cnt int) []types.Validator

RandVals returns a list of cnt validators for initializing the application. Note that the keys are deterministically derived from the index in the array, while the power is random (Change this if not desired)

func SetAccount

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

func TxID

func TxID(tx Tx) []byte

Types

type Account

type Account struct {
	PubKey  crypto.PubKey `json:"pub_key"` // May be nil, if not known.
	Height  int           `json:"height"`  // Hold the account balance at height
	Balance uint64        `json:"DMC"`
	Address data.Bytes    `json:"address"`
}

func GetAccount

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

func GetAllAccounts

func GetAllAccounts(store KVS) []Account

func GetAllAccountsInSegment

func GetAllAccountsInSegment(store KVS, addr []byte, prefixSize int) []Account

func TopkAccounts

func TopkAccounts(acc []Account, k int) []Account

func (*Account) Copy

func (acc *Account) Copy() *Account

func (*Account) String

func (acc *Account) String() string

type AccountGetter

type AccountGetter interface {
	GetAccount(addr []byte) *Account
	GetAllAccountsInSegment(addr []byte, prefixSize int) []Account
}

type AccountGetterSetter

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

type AccountSetter

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

type Accounts

type Accounts []Account

*

  • Slice of accounts and function to sort them
  • for selecting the top k validators?

type AppTx

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

----------------------------------------------------------------------------- For smart contracts

func (*AppTx) AssertIsTx

func (_ *AppTx) AssertIsTx()

func (*AppTx) SetSignature

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

func (*AppTx) SignBytes

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

func (*AppTx) String

func (tx *AppTx) String() string

type DMCCoinApplication

type DMCCoinApplication struct {
	types.BaseApplication

	ValUpdates []types.Validator
	// contains filtered or unexported fields
}

func NewDMCCoinApplication

func NewDMCCoinApplication(logger log.Logger) *DMCCoinApplication

func (*DMCCoinApplication) CheckTx

func (app *DMCCoinApplication) CheckTx(txBytes []byte, height int64) types.ResponseCheckTx

func (*DMCCoinApplication) Commit

func (app *DMCCoinApplication) Commit() types.ResponseCommit

func (*DMCCoinApplication) DeliverBucketedTx

func (app *DMCCoinApplication) DeliverBucketedTx(txBytes []byte, height int64, bucketID string) (res types.ResponseDeliverTx)

func (*DMCCoinApplication) DeliverTx

func (app *DMCCoinApplication) DeliverTx(txBytes []byte, height int64) types.ResponseDeliverTx

tx is either "key=value" or just arbitrary bytes

func (*DMCCoinApplication) GetState

func (app *DMCCoinApplication) GetState() *State

func (*DMCCoinApplication) GetValidatorSet

func (app *DMCCoinApplication) GetValidatorSet(height int64) (res types.ResponseGetValidatorSet)

FIXME: At the moment this call is also used to get UTXO account balances

func (*DMCCoinApplication) Info

func (app *DMCCoinApplication) Info(req types.RequestInfo) (resInfo types.ResponseInfo)

func (*DMCCoinApplication) Query

func (app *DMCCoinApplication) Query(reqQuery types.RequestQuery) (resQuery types.ResponseQuery)

func (*DMCCoinApplication) SetInitAccount

func (app *DMCCoinApplication) SetInitAccount(address data.Bytes, balance uint64)

type DMCTx

type DMCTx struct {
	Fee    uint64   `json:"Fee"`
	Input  TxInput  `json:"Input"`
	Output TxOutput `json:"Output"`
}

func (*DMCTx) AssertIsTx

func (_ *DMCTx) AssertIsTx()

func (*DMCTx) SetSignature

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

func (*DMCTx) SignBytes

func (tx *DMCTx) SignBytes() []byte

func (*DMCTx) String

func (tx *DMCTx) String() string

type KVCache

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

A Cache that enforces deterministic sync order.

func NewKVCache

func NewKVCache(store KVS) *KVCache

NOTE: If store is nil, creates a new MemKVStore

func (*KVCache) ClearLogLines

func (kvc *KVCache) ClearLogLines()

func (*KVCache) Get

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

func (*KVCache) GetAll

func (kvc *KVCache) GetAll(key []byte, prefixSize int) (value []byteArray)

func (*KVCache) GetLogLines

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

func (*KVCache) Reset

func (kvc *KVCache) Reset() *KVCache

func (*KVCache) Set

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

func (*KVCache) SetLogging

func (kvc *KVCache) SetLogging()

func (*KVCache) Sync

func (kvc *KVCache) Sync()

Update the store with the values from the cache

type KVS

type KVS interface {
	Set(key, value []byte)
	Get(key []byte) (value []byte)
	GetAll(key []byte, prefixSize int) (value []byteArray)
	GetAllAcc() (value []byteArray)
}

type MemKVS

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

func NewMemKVS

func NewMemKVS() *MemKVS

func (*MemKVS) Get

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

func (*MemKVS) GetAll

func (mkv *MemKVS) GetAll(key []byte, prefixSize int) (value []byteArray)

func (*MemKVS) GetAllAcc

func (mkv *MemKVS) GetAllAcc() (value []byteArray)

func (*MemKVS) Set

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

type PrivAccount

type PrivAccount struct {
	crypto.PrivKey
	Account
}

type State

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

func NewState

func NewState(store KVS, logger log.Logger) *State

func (*State) CacheSync

func (s *State) CacheSync()

NOTE: errors if s is not from CacheWrap()

func (*State) Commit

func (s *State) Commit() string

func (*State) Get

func (s *State) Get(key []byte) (value []byte)

func (*State) GetAccount

func (s *State) GetAccount(addr []byte) *Account

func (*State) GetAll

func (s *State) GetAll(key []byte, prefixSize int) (value []byteArray)

func (*State) GetAllAccounts

func (s *State) GetAllAccounts() []Account

func (*State) GetAllAccountsInSegment

func (s *State) GetAllAccountsInSegment(addr []byte, prefixSize int) []Account

func (*State) GetChainID

func (s *State) GetChainID() string

func (*State) Set

func (s *State) Set(key []byte, value []byte)

func (*State) SetAccount

func (s *State) SetAccount(addr []byte, acc *Account)

func (*State) SetChainID

func (s *State) SetChainID(chainID string)

func (*State) SetLogger

func (s *State) SetLogger(l log.Logger)

type Tx

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

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

Account Types:

  • DMCTx Send coins to address
  • TxUTXO Account balance update FIXME: Rename UTXO to UABC

type TxInput

type TxInput struct {
	Address   data.Bytes       `json:"address"`   // Hash of the PubKey
	Coins     uint64           `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 NewTxInput

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

func (TxInput) String

func (txIn TxInput) String() string

func (TxInput) ValidateBasic

func (txIn TxInput) ValidateBasic() int

type TxOutput

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

func (TxOutput) ChainAndAddress

func (txOut TxOutput) ChainAndAddress() ([]byte, []byte, int)

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

func (txOut TxOutput) String() string

func (TxOutput) ValidateBasic

func (txOut TxOutput) ValidateBasic() int

type TxS

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

TxS add json serialization to Tx

func (TxS) MarshalJSON

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

func (*TxS) UnmarshalJSON

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

type TxUTXO

type TxUTXO struct {
	Address data.Bytes `json:"address"` // Hash of the PubKey
	Balance uint64     `json:"coins"`   //
}

func (*TxUTXO) AssertIsTx

func (_ *TxUTXO) AssertIsTx()

func (*TxUTXO) SignBytes

func (tx *TxUTXO) SignBytes() []byte

Jump to

Keyboard shortcuts

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