types

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OK - all is bueno with the executed Tx. Any non-zero code is an error
	OK uint32 = iota
	// HandlerNotFound - yep...we couldn't find it
	HandlerNotFound
	// BadTx - no bueno, couldn't decode it or something like that
	BadTx
	// NotFound - catch all
	NotFound
	// BadQuery - in store query
	BadQuery
)

Variables

This section is empty.

Functions

func EncodeTx

func EncodeTx(tx *SignedTransaction) ([]byte, error)

EncodeTx returns a []byte or error

Types

type Cache

type Cache interface {
	KVStore
	// Dump the cache to the tree
	ApplyToState()
}

Cache extends KVStore adding an additional method to implement on a cache

type CommitInfo

type CommitInfo struct {
	Hash                 []byte   `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
	Version              int64    `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

State commit information

func (*CommitInfo) Descriptor

func (*CommitInfo) Descriptor() ([]byte, []int)

func (*CommitInfo) GetHash

func (m *CommitInfo) GetHash() []byte

func (*CommitInfo) GetVersion

func (m *CommitInfo) GetVersion() int64

func (*CommitInfo) ProtoMessage

func (*CommitInfo) ProtoMessage()

func (*CommitInfo) Reset

func (m *CommitInfo) Reset()

func (*CommitInfo) String

func (m *CommitInfo) String() string

func (*CommitInfo) XXX_DiscardUnknown

func (m *CommitInfo) XXX_DiscardUnknown()

func (*CommitInfo) XXX_Marshal

func (m *CommitInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*CommitInfo) XXX_Merge

func (m *CommitInfo) XXX_Merge(src proto.Message)

func (*CommitInfo) XXX_Size

func (m *CommitInfo) XXX_Size() int

func (*CommitInfo) XXX_Unmarshal

func (m *CommitInfo) XXX_Unmarshal(b []byte) error

type KVStore

type KVStore interface {
	// Get from the cache or tree
	Get(key []byte) ([]byte, error)
	// Get only from committed data
	GetCommitted(key []byte) ([]byte, error)
	// Set to the cache or tree
	Set(key, value []byte)
	// Delete a key/value pair
	Delete(key []byte)
	// IterateKeyRange over the tree
	IterateKeyRange(start, end []byte, ascending bool, fn func(key []byte, value []byte) bool) bool
}

KVStore is the base interface for all methods related to a store. See the store package

type QueryStore added in v0.3.0

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

func NewQueryStore added in v0.3.0

func NewQueryStore(service string, store Cache) QueryStore

func (QueryStore) Get added in v0.3.0

func (qs QueryStore) Get(key []byte) ([]byte, error)

type RWStore added in v0.3.0

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

Store for Service Txs

func NewRWStore added in v0.3.0

func NewRWStore(service string, store Cache) RWStore

func (RWStore) Delete added in v0.3.0

func (rw RWStore) Delete(key []byte)

func (RWStore) Get added in v0.3.0

func (rw RWStore) Get(key []byte) ([]byte, error)

func (RWStore) Insert added in v0.3.0

func (rw RWStore) Insert(key, value []byte)

type Result

type Result struct {
	Code uint32 // Any non-zero code is an error
	Data []byte
	Log  string
}

Result is it returned from a menta app TxHandler By default 'Code' will be zero which mean 'Ok' to tendermint

func ErrorBadTx

func ErrorBadTx() Result

ErrorBadTx is returned when menta can't deserialize a Tx

func ErrorNoHandler

func ErrorNoHandler() Result

ErrorNoHandler is returned when menta can't find a handler for a given route

func ResultError

func ResultError(code uint32, log string) Result

ResultError is returned on an error with a non-zero code

type Service added in v0.3.0

type Service interface {
	// Route is the unique name of the service. Used to register your service in Menta
	Route() string
	// Init is called once, on the very first run of the application.
	// Use this to load genesis data for your service
	Init(RWStore)
	// Execute is the primary business logic of your service. This is the blockchain
	// state transistion function
	Execute(*SignedTransaction, RWStore) Result
	// Query provides read access to service storage.
	Query([]byte, QueryStore) Result
}

Service is the primary interface to implement for application services. A given MentaApp may have 1 or more of these.

type SignedTransaction added in v0.3.0

type SignedTransaction struct {
	Service              string   `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
	Sender               []byte   `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"`
	Msgid                uint32   `protobuf:"varint,3,opt,name=msgid,proto3" json:"msgid,omitempty"`
	Msg                  []byte   `protobuf:"bytes,4,opt,name=msg,proto3" json:"msg,omitempty"`
	Nonce                []byte   `protobuf:"bytes,5,opt,name=nonce,proto3" json:"nonce,omitempty"`
	Sig                  []byte   `protobuf:"bytes,6,opt,name=sig,proto3" json:"sig,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Transaction model across client and node.

'msg' is a []byte of application specific content, the application is reponsible for encoding/decoding it.

func DecodeTx

func DecodeTx(raw []byte) (*SignedTransaction, error)

DecodeTx returns a Tx from a []byte

func (*SignedTransaction) Descriptor added in v0.3.0

func (*SignedTransaction) Descriptor() ([]byte, []int)

func (*SignedTransaction) GetMsg added in v0.3.0

func (m *SignedTransaction) GetMsg() []byte

func (*SignedTransaction) GetMsgid added in v0.3.0

func (m *SignedTransaction) GetMsgid() uint32

func (*SignedTransaction) GetNonce added in v0.3.0

func (m *SignedTransaction) GetNonce() []byte

func (*SignedTransaction) GetSender added in v0.3.0

func (m *SignedTransaction) GetSender() []byte

func (*SignedTransaction) GetService added in v0.3.0

func (m *SignedTransaction) GetService() string

func (*SignedTransaction) GetSig added in v0.3.0

func (m *SignedTransaction) GetSig() []byte

func (*SignedTransaction) ProtoMessage added in v0.3.0

func (*SignedTransaction) ProtoMessage()

func (*SignedTransaction) Reset added in v0.3.0

func (m *SignedTransaction) Reset()

func (*SignedTransaction) Sign added in v0.3.0

Sign a transaction

func (*SignedTransaction) String added in v0.3.0

func (m *SignedTransaction) String() string

func (*SignedTransaction) Verify added in v0.3.0

func (tx *SignedTransaction) Verify(pubKey crypto.PublicKeyEd25519) bool

Verify a Tx against a given public key

func (*SignedTransaction) XXX_DiscardUnknown added in v0.3.0

func (m *SignedTransaction) XXX_DiscardUnknown()

func (*SignedTransaction) XXX_Marshal added in v0.3.0

func (m *SignedTransaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SignedTransaction) XXX_Merge added in v0.3.0

func (m *SignedTransaction) XXX_Merge(src proto.Message)

func (*SignedTransaction) XXX_Size added in v0.3.0

func (m *SignedTransaction) XXX_Size() int

func (*SignedTransaction) XXX_Unmarshal added in v0.3.0

func (m *SignedTransaction) XXX_Unmarshal(b []byte) error

type Store

type Store interface {
	KVStore
	// Commit is called on Abci commit to commit the tree to storage and update the hash
	Commit() CommitInfo
	// Close the store
	Close()
	// Refresh the check/deliver caches
	RefreshCache() Cache
}

Store extends KVStore

type Tag

type Tag = cmn.KVPair

Tag defined in tendermint ... common/types.proto

type Tags

type Tags cmn.KVPairs

Tags defined in tendermint ... common/kvpairs.go = []cmn.KVPairs

type ValidateTxHandler added in v0.3.0

type ValidateTxHandler func(*SignedTransaction, RWStore) Result

ValidateTxHandler should be implemented to validate/check a transaction for inclusion into the mempool. This is called on 'checkTx'. A returned non-zero result.Code will exclude a transaction from consideration. A Menta application has only 1 of these

Jump to

Keyboard shortcuts

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