tmpop

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GetInfo      = "GetInfo"
	GetSegment   = "GetSegment"
	FindSegments = "FindSegments"
	GetMapIDs    = "GetMapIDs"
	GetValue     = "GetValue"
)

Query types.

View Source
const (
	// Name of the Tendermint Application.
	Name = "TMPop"

	// Description of this Tendermint Application.
	Description = "Agent Store in a Blockchain"

	// DefaultCacheSize is the default size of the DB cache.
	DefaultCacheSize = 0
)
View Source
const (
	// CodeTypeValidation is the ABCI error code for a validation error.
	CodeTypeValidation abci.CodeType = 400
)

Variables

This section is empty.

Functions

func BuildQueryBinary

func BuildQueryBinary(args interface{}) (argsBytes []byte, err error)

BuildQueryBinary outputs the marshalled Query.

func Run

func Run(a store.Adapter, config *Config)

Run launches a TMPop Tendermint App

Types

type BatchAdapter

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

BatchAdapter implements github.com/tendermint/tmlibs/db/db.Batch.

func NewBatchAdapter

func NewBatchAdapter(batch store.Batch) *BatchAdapter

NewBatchAdapter returns a new Batch Adapter

func (*BatchAdapter) Delete

func (b *BatchAdapter) Delete(key []byte)

Delete implements github.com/tendermint/tmlibs/db/db.Batch.Delete

func (*BatchAdapter) Set

func (b *BatchAdapter) Set(key, value []byte)

Set implements github.com/tendermint/tmlibs/db/db.Batch.Set

func (*BatchAdapter) Write

func (b *BatchAdapter) Write()

Write implements github.com/tendermint/tmlibs/db/db.Batch.Write

type Commit

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

Commit represents a committed state of the blockchain. It uses a tree to store all linkhashes and have a canonical app for the state of the application. It uses a store for indexed search but all results from the store must be checked within the tree.

func (*Commit) FindSegments

func (c *Commit) FindSegments(filter *store.SegmentFilter) ([]*cs.Segment, [][]byte, error)

FindSegments emulates github.com/stratumn/sdk/store.Adapter.FindSegments. with additional proofs.

func (*Commit) GetMapIDs

func (c *Commit) GetMapIDs(filter *store.MapFilter) ([]string, error)

GetMapIDs implements github.com/stratumn/sdk/store.Adapter.GetMapIDs. It might be out of sync with the tree.

func (*Commit) GetSegment

func (c *Commit) GetSegment(lh *types.Bytes32) (*cs.Segment, []byte, error)

GetSegment emulates github.com/stratumn/sdk/store.Adapter.GetSegments. GetSegment returns a segment and its proof.

func (*Commit) Hash

func (c *Commit) Hash() []byte

Hash returns the current hash of the Commit (root hash of the tree).

func (*Commit) Proof

func (c *Commit) Proof(key []byte) ([]byte, []byte, bool)

Proof returns the Merkle Proof of a given key.

func (*Commit) Size

func (c *Commit) Size() int

Size returns the current number of values stored.

type Config

type Config struct {
	// A version string that will be set in the store's information.
	Version string

	// A git commit hash that will be set in the store's information.
	Commit string

	// The DB cache size.
	CacheSize int

	// JSON schema rules definition
	ValidatorFilename string
}

Config contains configuration options for the App.

type DBAdapter

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

DBAdapter implements github.com/tendermint/tmlibs/db/db.DB.

func NewDBAdapter

func NewDBAdapter(a store.Adapter) *DBAdapter

NewDBAdapter returns a new DB Adapter

func (*DBAdapter) Close

func (a *DBAdapter) Close()

Close implements github.com/tendermint/tmlibs/db/db.DB.Close

func (*DBAdapter) Delete

func (a *DBAdapter) Delete(key []byte)

Delete implements github.com/tendermint/tmlibs/db/db.DB.Delete

func (*DBAdapter) DeleteSync

func (a *DBAdapter) DeleteSync(key []byte)

DeleteSync implements github.com/tendermint/tmlibs/db/db.DB.DeleteSync

func (*DBAdapter) Get

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

Get implements github.com/tendermint/tmlibs/db/db.DB.Get

func (*DBAdapter) Iterator

func (a *DBAdapter) Iterator() db.Iterator

Iterator implements github.com/tendermint/tmlibs/db/db.DB.Iterator. Iterator is for debugging.

func (*DBAdapter) NewBatch

func (a *DBAdapter) NewBatch() db.Batch

NewBatch implements github.com/tendermint/tmlibs/db/db.DB.NewBatch

func (*DBAdapter) Print

func (a *DBAdapter) Print()

Print implements github.com/tendermint/tmlibs/db/db.DB.Print. Print is for debugging

func (*DBAdapter) Set

func (a *DBAdapter) Set(key, value []byte)

Set implements github.com/tendermint/tmlibs/db/db.DB.Set

func (*DBAdapter) SetAdapter

func (a *DBAdapter) SetAdapter(adapter store.Adapter)

SetAdapter sets a new adapter on the DB

func (*DBAdapter) SetSync

func (a *DBAdapter) SetSync(key, value []byte)

SetSync implements github.com/tendermint/tmlibs/db/db.DB.SetSync

func (*DBAdapter) Stats

func (a *DBAdapter) Stats() map[string]string

Stats implements github.com/tendermint/tmlibs/db/db.DB.Stats. Stats is for debugging.

type Info

type Info struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Version     string      `json:"version"`
	Commit      string      `json:"commit"`
	AdapterInfo interface{} `json:"adapterInfo"`
}

Info is the info returned by GetInfo.

type Snapshot

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

Snapshot represents a version of the state.

func (*Snapshot) DeleteSegment

func (s *Snapshot) DeleteSegment(lh *types.Bytes32) (*cs.Segment, bool, error)

DeleteSegment removes a Segment from the Snapshot.

func (*Snapshot) DeleteValue

func (s *Snapshot) DeleteValue(key []byte) ([]byte, bool)

DeleteValue removes a value from the Snapshot.

func (*Snapshot) SaveValue

func (s *Snapshot) SaveValue(key, value []byte) bool

SaveValue adds a new value in the Snapshot.

func (*Snapshot) SetSegment

func (s *Snapshot) SetSegment(segment *cs.Segment) error

SetSegment adds a new Segment in the Snapshot.

type State

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

State represents the app states, separating the commited state (for queries) from the working state (for CheckTx and AppendTx).

func NewState

func NewState(tree merkle.Tree, a store.Adapter) (*State, error)

NewState creates a new State.

func (State) Append

func (s State) Append() *Snapshot

Append returns the version of the state affected by appended transaction from the current block.

func (State) Check

func (s State) Check() *Snapshot

Check returns the version of the state affected by checked transaction from the memory pool.

func (*State) Commit

func (s *State) Commit() ([]byte, error)

Commit stores the current Append() state as committed starts new Append/Check state, and returns the hash for the commit.

func (State) Committed

func (s State) Committed() *Commit

Committed returns the committed state.

type TMPop

type TMPop struct {
	abci.BaseApplication
	// contains filtered or unexported fields
}

TMPop is the type of the application that implements github.com/tendermint/abci/types.Application, the tendermint socket protocol (ABCI).

func New

func New(a store.Adapter, config *Config) (*TMPop, error)

New creates a new instance of a TMPop.

func (*TMPop) BeginBlock

func (t *TMPop) BeginBlock(req abci.RequestBeginBlock)

BeginBlock implements github.com/tendermint/abci/types.Application.BeginBlock.

func (*TMPop) CheckTx

func (t *TMPop) CheckTx(tx []byte) abci.Result

CheckTx implements github.com/tendermint/abci/types.Application.CheckTx.

func (*TMPop) Commit

func (t *TMPop) Commit() abci.Result

Commit implements github.com/tendermint/abci/types.Application.Commit. It actually commits the current state in the Store.

func (*TMPop) DeliverTx

func (t *TMPop) DeliverTx(tx []byte) abci.Result

DeliverTx implements github.com/tendermint/abci/types.Application.DeliverTx.

func (*TMPop) Info

func (t *TMPop) Info(req abci.RequestInfo) abci.ResponseInfo

Info implements github.com/tendermint/abci/types.Application.Info.

func (*TMPop) Query

func (t *TMPop) Query(reqQuery abci.RequestQuery) (resQuery abci.ResponseQuery)

Query implements github.com/tendermint/abci/types.Application.Query.

func (*TMPop) SetOption

func (t *TMPop) SetOption(key string, value string) (log string)

SetOption implements github.com/tendermint/abci/types.Application.SetOption.

type Tx

type Tx struct {
	TxType   TxType         `json:"type"`
	Segment  *cs.Segment    `json:"segment"`
	LinkHash *types.Bytes32 `json:"linkhash"`
	Key      []byte         `json:"key"`
	Value    []byte         `json:"value"`
}

Tx represents a TMPoP transaction

type TxType

type TxType byte

TxType represents the type of a Transaction (Write Segment/Value, Delete Segment/Value)

const (
	// SaveSegment characterizes a transaction that saves a new segment
	SaveSegment TxType = iota

	// DeleteSegment characterizes a transaction that deletes a segment
	DeleteSegment

	// SaveValue characterizes a transaction that saves a new value
	SaveValue

	// DeleteValue characterizes a transaction that deletes a value
	DeleteValue
)

Jump to

Keyboard shortcuts

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