abcilayers

package
v0.0.0-...-ebac000 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Implements generic layers for building ABCI-applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppMetadata

type AppMetadata struct {
	types.Application

	// The fields to set in Info-Responses
	Version    string
	AppVersion uint64
}

An ABCI-application layer, that sets the .Version and .AppVersion fields in Info-responses to specified values.

func (*AppMetadata) Info

type DedupLayer

type DedupLayer struct {
	types.Application
	DB dbm.DB

	KeyExtractor Tx2Key
	// contains filtered or unexported fields
}

An ABCI-application layer, that de-duplicates transactions. From the transaction, a key is extracted. If there is no such key extraction function, the transaction itself is the key.

The key is hashed with a 32-bit function (FNV1a) and truncated to 24-bit, so that maximum number of hash buckets is 2²⁴ (~ 16 millions).

In the case of a hash collision in the truncated 24-bit hash space, the algorithm can fail to detect some duplicate TX-keys, but the algorithm guarantees, that no TX-keys are falsely detected as duplicates.

The bucket numbers are formatted as hex with the "dedup" prefix, so that a key looks like "dedupF2A450".

func (*DedupLayer) CheckTx

func (d *DedupLayer) CheckTx(tx []byte) (q types.ResponseCheckTx)

func (*DedupLayer) Commit

func (d *DedupLayer) Commit() (a types.ResponseCommit)

func (*DedupLayer) DeliverTx

func (d *DedupLayer) DeliverTx(tx []byte) (q types.ResponseDeliverTx)

type HashCounter

type HashCounter struct {
	types.Application
	DB dbm.DB
	// contains filtered or unexported fields
}

An ABCI-application layer, that calculates a block-hash upon commit and implements the Info-method correctly (returning the latest Commit block height and app hash). It also hashes all transactions, that are successfully submitted through DeliverTx.

The user MAY optionallysupply a value in the database with the key "bcseed". This is like a shared secret, that must be the same on each Blockchain-member.

The layer manages a record with the key "info", which contains a JSON object holding the last Block-Height and the last App-Hash.

func (*HashCounter) Commit

func (t *HashCounter) Commit() types.ResponseCommit

func (*HashCounter) DeliverTx

func (t *HashCounter) DeliverTx(tx []byte) (a types.ResponseDeliverTx)

func (*HashCounter) EndBlock

func (*HashCounter) Info

func (*HashCounter) InitChain

func (*HashCounter) OnStart

func (t *HashCounter) OnStart() error

type HashMemory

type HashMemory struct {
	types.Application
	// contains filtered or unexported fields
}

An ABCI-application layer, wraps EndBlock and Commit and conveys both .LastBlockHeight end .LastBlockAppHash out to the Info-method.

This Method is only suited for transient, in-memory Applications.

func (*HashMemory) Commit

func (t *HashMemory) Commit() types.ResponseCommit

func (*HashMemory) EndBlock

func (*HashMemory) Info

type Tx2Key

type Tx2Key func(tx []byte) (key []byte)

func (Tx2Key) Extract

func (t Tx2Key) Extract(tx []byte) (key []byte)

Jump to

Keyboard shortcuts

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