app

package
v0.10.0 Latest Latest
Warning

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

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

Documentation

Overview

Package app is a generated protocol buffer package.

It is generated from these files:

app/results.proto

It has these top-level messages:

ResultSet

Index

Constants

View Source
const CodeNoSuchPath uint32 = 10

CodeNoSuchPath is an ABCI Response Codes Base SDK reserves 0 ~ 99. App uses 10 ~ 19

View Source
const DefaultRouterSize = 10

DefaultRouterSize preallocates this much space to hold routes

Variables

View Source
var (
	ErrInvalidLengthResults = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowResults   = fmt.Errorf("proto: integer overflow")
)

Functions

func ChainInitializers

func ChainInitializers(inits ...weave.Initializer) weave.Initializer

ChainInitializers lets you initialize many extensions with one function

func ErrNoSuchPath

func ErrNoSuchPath(path string) error

ErrNoSuchPath constructs an error when router doesn't know the path

func IsNoSuchPathErr

func IsNoSuchPathErr(err error) bool

IsNoSuchPathErr checks if this is an unknown route error

func JoinResults added in v0.2.0

func JoinResults(keys, values *ResultSet) ([]weave.Model, error)

JoinResults inverts ResultsFromKeys and ResultsFromValues and makes then a consistent whole again

func UnmarshalOneResult added in v0.2.0

func UnmarshalOneResult(bz []byte, o weave.Persistent) error

UnmarshalOneResult will parse a resultset, and it if is not empty, unmarshal the first result into o

Types

type BaseApp

type BaseApp struct {
	*StoreApp
	// contains filtered or unexported fields
}

BaseApp adds DeliverTx, CheckTx, and BeginBlock handlers to the storage and query functionality of StoreApp

func NewBaseApp

func NewBaseApp(store *StoreApp, decoder weave.TxDecoder,
	handler weave.Handler, ticker weave.Ticker, debug bool) BaseApp

NewBaseApp constructs a basic abci application

func (BaseApp) BeginBlock

func (b BaseApp) BeginBlock(req abci.RequestBeginBlock) (
	res abci.ResponseBeginBlock)

BeginBlock - ABCI

func (BaseApp) CheckTx

func (b BaseApp) CheckTx(txBytes []byte) abci.ResponseCheckTx

CheckTx - ABCI - dispatches to the handler

func (BaseApp) DeliverTx

func (b BaseApp) DeliverTx(txBytes []byte) abci.ResponseDeliverTx

DeliverTx - ABCI - dispatches to the handler

type Decorators

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

Decorators holds a chain of decorators, not yet resolved by a Handler

func ChainDecorators

func ChainDecorators(chain ...weave.Decorator) Decorators

ChainDecorators takes a chain of decorators, and upon adding a final Handler (often a Router), returns a Handler that will execute this whole stack.

app.ChainDecorators(
  util.NewLogging(),
  util.NewRecovery(),
  auth.NewDecorator(),
  coins.NewFeeDecorator(),
  util.NewSavepoint().OnDeliver(),
).WithHandler(
  myapp.NewRouter(),
)

func (Decorators) Chain

func (d Decorators) Chain(chain ...weave.Decorator) Decorators

Chain allows us to keep adding more Decorators to the chain

func (Decorators) WithHandler

func (d Decorators) WithHandler(h weave.Handler) weave.Handler

WithHandler resolves the stack and returns a concrete Handler that will pass through the chain of decorators before calling the final Handler.

type ResultSet added in v0.2.0

type ResultSet struct {
	Results [][]byte `protobuf:"bytes,1,rep,name=results" json:"results,omitempty"`
}

ResultSet contains a list of keys or values

func ResultsFromKeys added in v0.2.0

func ResultsFromKeys(models []weave.Model) *ResultSet

ResultsFromKeys returns a ResultSet of all keys given a set of models

func ResultsFromValues added in v0.2.0

func ResultsFromValues(models []weave.Model) *ResultSet

ResultsFromValues returns a ResultSet of all values given a set of models

func (*ResultSet) Descriptor added in v0.2.0

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

func (*ResultSet) GetResults added in v0.2.0

func (m *ResultSet) GetResults() [][]byte

func (*ResultSet) Marshal added in v0.2.0

func (m *ResultSet) Marshal() (dAtA []byte, err error)

func (*ResultSet) MarshalTo added in v0.2.0

func (m *ResultSet) MarshalTo(dAtA []byte) (int, error)

func (*ResultSet) ProtoMessage added in v0.2.0

func (*ResultSet) ProtoMessage()

func (*ResultSet) Reset added in v0.2.0

func (m *ResultSet) Reset()

func (*ResultSet) Size added in v0.2.0

func (m *ResultSet) Size() (n int)

func (*ResultSet) String added in v0.2.0

func (m *ResultSet) String() string

func (*ResultSet) Unmarshal added in v0.2.0

func (m *ResultSet) Unmarshal(dAtA []byte) error

type Router

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

Router allows us to register many handlers with different paths and then direct each message to the proper handler.

Minimal interface modeled after net/http.ServeMux

TODO: look for better trie routers that handle patterns... maybe take code from here? https://github.com/julienschmidt/httprouter https://github.com/julienschmidt/httprouter/blob/master/tree.go

func NewRouter

func NewRouter() Router

NewRouter initializes a router with no routes

func (Router) Check

func (r Router) Check(ctx weave.Context, store weave.KVStore,
	tx weave.Tx) (weave.CheckResult, error)

Check dispatches to the proper handler based on path

func (Router) Deliver

func (r Router) Deliver(ctx weave.Context, store weave.KVStore,
	tx weave.Tx) (weave.DeliverResult, error)

Deliver dispatches to the proper handler based on path

func (Router) Handle

func (r Router) Handle(path string, h weave.Handler)

Handle adds a new Handler for the given path. panics if another Handler was already registered

func (Router) Handler

func (r Router) Handler(path string) weave.Handler

Handler returns the registered Handler for this path. If no path is found, returns a noSuchPath Handler Always returns a non-nil Handler

type StoreApp

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

StoreApp contains a data store and all info needed to perform queries and handshakes.

It should be embedded in another struct for CheckTx, DeliverTx and initializing state from the genesis. Errors on ABCI steps handled as panics I'm sorry Alex, but there is no other way :( https://github.com/tendermint/tendermint/abci/issues/165#issuecomment-353704015 "Regarding errors in general, for messages that don't take

user input like Flush, Info, InitChain, BeginBlock, EndBlock,

and Commit.... There is no way to handle these errors gracefully, so we might as well panic."

func NewStoreApp

func NewStoreApp(name string, store weave.CommitKVStore,
	queryRouter weave.QueryRouter, baseContext weave.Context) *StoreApp

NewStoreApp initializes this app into a ready state with some defaults

panics if unable to properly load the state from the given store TODO: is this correct? nothing else to do really....

func (*StoreApp) AddValChange

func (s *StoreApp) AddValChange(diffs []abci.ValidatorUpdate)

AddValChange is meant to be called by apps on DeliverTx results, this is added to the cache for the endblock changeset

func (*StoreApp) BeginBlock

func (s *StoreApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock)

BeginBlock implements ABCI Sets up blockContext TODO: investigate response tags as of 0.11 abci

func (*StoreApp) BlockContext

func (s *StoreApp) BlockContext() weave.Context

BlockContext returns the block context for public use

func (*StoreApp) CheckStore

func (s *StoreApp) CheckStore() weave.CacheableKVStore

CheckStore returns the current CheckTx cache for methods

func (*StoreApp) Commit

func (s *StoreApp) Commit() (res abci.ResponseCommit)

Commit implements abci.Application

func (*StoreApp) DeliverStore

func (s *StoreApp) DeliverStore() weave.CacheableKVStore

DeliverStore returns the current DeliverTx cache for methods

func (*StoreApp) EndBlock

func (s *StoreApp) EndBlock(_ abci.RequestEndBlock) (res abci.ResponseEndBlock)

EndBlock - ABCI Returns a list of all validator changes made in this block TODO: investigate response tags as of 0.11 abci

func (*StoreApp) GetChainID

func (s *StoreApp) GetChainID() string

GetChainID returns the current chainID

func (*StoreApp) Info

func (s *StoreApp) Info(req abci.RequestInfo) abci.ResponseInfo

Info implements abci.Application. It returns the height and hash, as well as the abci name and version.

The height is the block that holds the transactions, not the apphash itself.

func (*StoreApp) InitChain

func (s *StoreApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitChain)

InitChain implements ABCI TODO: store the original validators somewhere Note: in tendermint 0.17, the genesis file is passed in here, we should use this to trigger reading the genesis now TODO: investigate validators and consensusParams in response

func (*StoreApp) Logger

func (s *StoreApp) Logger() log.Logger

Logger returns the application base logger

func (*StoreApp) Query

func (s *StoreApp) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQuery)

Query gets data from the app store. A query request has the following elements: * Path - the type of query * Data - what to query, interpretted based on Path * Height - the block height to query (if 0 most recent) * Prove - if true, also return a proof

Path may be "/", "/<bucket>", or "/<bucket>/<index>" It may be followed by "?prefix" to make a prefix query. Soon we will support "?range" for powerful range queries

Key and Value in Results are always serialized ResultSet objects, able to support 0 to N values. They must be the same size. This makes things a little more difficult for simple queries, but provides a consistent interface.

func (*StoreApp) SetOption

SetOption - ABCI TODO: not implemented (ABCI spec still unclear....)

func (*StoreApp) WithInit

func (s *StoreApp) WithInit(init weave.Initializer) *StoreApp

WithInit is used to set the init function we call

func (*StoreApp) WithLogger

func (s *StoreApp) WithLogger(logger log.Logger) *StoreApp

WithLogger sets the logger on the StoreApp and returns it, to make it easy to chain in initialization

also sets baseContext logger

Jump to

Keyboard shortcuts

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