counter

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: Apache-2.0 Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ServiceName = "counter_example"

ServiceName is just that...

Variables

This section is empty.

Functions

This section is empty.

Types

type CountValue

type CountValue struct {
	Current              uint32   `protobuf:"varint,1,opt,name=current,proto3" json:"current,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Storage

func DecodeCount

func DecodeCount(raw []byte) (*CountValue, error)

DecodeCount bytes => Countvalue

func NewCounter

func NewCounter(val uint32) *CountValue

NewCounter set to 'val'

func (*CountValue) Descriptor

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

func (*CountValue) Encode

func (count *CountValue) Encode() ([]byte, error)

Encode the Counter

func (*CountValue) GetCurrent

func (m *CountValue) GetCurrent() uint32

func (*CountValue) Inc

func (count *CountValue) Inc()

Inc - increments the counter by 1

func (*CountValue) ProtoMessage

func (*CountValue) ProtoMessage()

func (*CountValue) Reset

func (m *CountValue) Reset()

func (*CountValue) String

func (m *CountValue) String() string

func (*CountValue) ValidNextValue

func (count *CountValue) ValidNextValue(proposed uint32) bool

ValidNextValue check if the proposed count is correct

func (*CountValue) XXX_DiscardUnknown

func (m *CountValue) XXX_DiscardUnknown()

func (*CountValue) XXX_Marshal

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

func (*CountValue) XXX_Merge

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

func (*CountValue) XXX_Size

func (m *CountValue) XXX_Size() int

func (*CountValue) XXX_Unmarshal

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

type Increment

type Increment struct {
	Value                uint32   `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Message

func (*Increment) Descriptor

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

func (*Increment) Encode

func (inc *Increment) Encode() ([]byte, error)

Encode the Increment message

func (*Increment) GetValue

func (m *Increment) GetValue() uint32

func (*Increment) ProtoMessage

func (*Increment) ProtoMessage()

func (*Increment) Reset

func (m *Increment) Reset()

func (*Increment) String

func (m *Increment) String() string

func (*Increment) XXX_DiscardUnknown

func (m *Increment) XXX_DiscardUnknown()

func (*Increment) XXX_Marshal

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

func (*Increment) XXX_Merge

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

func (*Increment) XXX_Size

func (m *Increment) XXX_Size() int

func (*Increment) XXX_Unmarshal

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

type QuerySchema added in v0.4.1

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

QuerySchema is really overkill for this example, but it's here for demo purposes It provides a Prefixed wrapper to a snapshot of the state store

func NewQuerySchema added in v0.4.1

func NewQuerySchema(store sdk.Snapshot) QuerySchema

func (QuerySchema) GetCountByKey added in v0.4.1

func (qs QuerySchema) GetCountByKey(k []byte) sdk.Result

type Schema

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

Schema wraps a prefixed store for our service

func NewSchema

func NewSchema(store sdk.Cache) Schema

func (Schema) IncrementCount

func (schema Schema) IncrementCount(sender []byte, msg Increment) sdk.Result

IncrementCount is the core logic for a tx

type Service

type Service struct{}

Service is a simple service to demonstrate the menta API. It stores a counter for each tx.sender

func (Service) Execute

func (srv Service) Execute(sender []byte, msgid uint32, message []byte, store sdk.Cache) sdk.Result

Execute runs the core logic for a state transition

func (Service) Initialize

func (srv Service) Initialize(data []byte, store sdk.Cache)

Initialize is called on the genesis block. Not used

func (Service) Name

func (srv Service) Name() string

Name is a unique name used to register the service

func (Service) Query

func (srv Service) Query(key []byte, store sdk.Snapshot) sdk.Result

Query committed state for the given used. Key is the public key bytes

type Wallet

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

func CreateWallet

func CreateWallet() Wallet

func WalletFromSeed

func WalletFromSeed(seed string) Wallet

func (Wallet) NewTx

func (wallet Wallet) NewTx(val uint32) ([]byte, error)

func (Wallet) PubKey

func (wallet Wallet) PubKey() []byte

Jump to

Keyboard shortcuts

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