app

package
v0.14.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

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 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 ABCIStore added in v0.14.0

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

ABCIStore exposes the weave abci.Query interface as a ReadonlyKVStore

func NewABCIStore added in v0.14.0

func NewABCIStore(app abci.Application) *ABCIStore

func (*ABCIStore) Get added in v0.14.0

func (a *ABCIStore) Get(key []byte) []byte

Get will query for exactly one value over the abci store. This can be wrapped with a bucket to reuse key/index/parse logic

func (*ABCIStore) Has added in v0.14.0

func (a *ABCIStore) Has(key []byte) bool

Has returns true if the given key in in the abci app store

func (*ABCIStore) Iterator added in v0.14.0

func (a *ABCIStore) Iterator(start, end []byte) weave.Iterator

Iterator attempts to do a range iteration over the store, We only support prefix queries in the abci server for now. This client only supports listing everything...

func (*ABCIStore) ReverseIterator added in v0.14.0

func (a *ABCIStore) ReverseIterator(start, end []byte) weave.Iterator

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 CommitStore added in v0.10.2

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

CommitStore handles loading from a KVCommitStore, maintaining different CacheWraps for Deliver and Check, and returning useful state info.

func NewCommitStore added in v0.10.2

func NewCommitStore(store weave.CommitKVStore) *CommitStore

NewCommitStore loads the CommitKVStore from disk or panics. It sets up the deliver and check caches.

func (*CommitStore) CheckStore added in v0.10.2

func (cs *CommitStore) CheckStore() weave.CacheableKVStore

CheckStore returns a store implementation that must be used during the checking phase.

func (*CommitStore) Commit added in v0.10.2

func (cs *CommitStore) Commit() weave.CommitID

Commit will flush deliver to the underlying store and commit it to disk. It then regenerates new deliver/check caches

TODO: this should probably be protected by a mutex.... need to think what concurrency we expect

func (*CommitStore) CommitInfo added in v0.10.2

func (cs *CommitStore) CommitInfo() (version int64, hash []byte)

CommitInfo returns the current height and hash

func (*CommitStore) DeliverStore added in v0.10.2

func (cs *CommitStore) DeliverStore() weave.CacheableKVStore

DeliverStore returns a store implementation that must be used during the delivery phase.

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,proto3" 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

func (*ResultSet) XXX_DiscardUnknown added in v0.12.0

func (m *ResultSet) XXX_DiscardUnknown()

func (*ResultSet) XXX_Marshal added in v0.12.0

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

func (*ResultSet) XXX_Merge added in v0.12.0

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

func (*ResultSet) XXX_Size added in v0.12.0

func (m *ResultSet) XXX_Size() int

func (*ResultSet) XXX_Unmarshal added in v0.12.0

func (m *ResultSet) XXX_Unmarshal(b []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 SliceIterator added in v0.14.0

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

SliceIterator wraps an Iterator over a slice of models

TODO: make this private and only expose Iterator interface????

func NewSliceIterator added in v0.14.0

func NewSliceIterator(data []weave.Model) *SliceIterator

NewSliceIterator creates a new Iterator over this slice

func (*SliceIterator) Close added in v0.14.0

func (s *SliceIterator) Close()

Close releases the Iterator.

func (*SliceIterator) Key added in v0.14.0

func (s *SliceIterator) Key() (key []byte)

Key returns the key of the cursor.

func (*SliceIterator) Next added in v0.14.0

func (s *SliceIterator) Next()

Next moves the iterator to the next sequential key in the database, as defined by order of iteration.

If Valid returns false, this method will panic.

func (*SliceIterator) Valid added in v0.14.0

func (s *SliceIterator) Valid() bool

Valid implements Iterator and returns true iff it can be read

func (*SliceIterator) Value added in v0.14.0

func (s *SliceIterator) Value() (value []byte)

Value returns the value of the cursor.

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