pkg

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "block-metrics"

Variables

View Source
var (
	ErrNotImplemented = errors.Register(ModuleName, 1, "not implemented")
	ErrFailedResponse = errors.Register(ModuleName, 2, "failed response")
	ErrConflict       = errors.Register(ModuleName, 3, "conflict")
	ErrLimit          = errors.Register(ModuleName, 4, "limit")
	ErrNotFound       = errors.Register(ModuleName, 5, "not found")
	ErrDenom          = errors.Register(ModuleName, 6, "denomination not supported")
)
View Source
var ModuleCdc *codec.Codec

Functions

func EnsureSchema

func EnsureSchema(pg *sql.DB) error

func FetchGenesis

func FetchGenesis(ctx context.Context, c *TendermintClient) (*domain.GenesisState, error)

func Sync

func Sync(ctx context.Context, tmc *TendermintClient, st *Store, hrp string) (uint, error)

Sync uploads to local store all blocks that are not present yet, starting with the blocks with the lowest hight first. It always returns the number of blocks inserted, even if returning an error.

Types

type ABCIInfo

type ABCIInfo struct {
	LastBlockHeight int64 `json:"last_block_height"`
}

func AbciInfo

func AbciInfo(c *TendermintClient) (*ABCIInfo, error)

AbciInfo returns abci_info.

type Block

type Block struct {
	Height  int64     `json:"height"`
	Hash    string    `json:"hash"`
	Time    time.Time `json:"time"`
	FeeFrac uint64    `json:"fee_frac"`
}

type Configuration

type Configuration struct {
	DBHost string
	DBUser string
	DBPass string
	DBName string
	DBSSL  string
	// Tendermint websocket URI
	TendermintWsURI string
	// Derivation path: "tiov" or "iov"
	Hrp   string
	Denom string
}

type QueryError

type QueryError struct {
	Query string
	Args  []interface{}
	Err   error
}

func (*QueryError) Error

func (e *QueryError) Error() string

type Store

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

func NewStore

func NewStore(db *sql.DB) *Store

NewStore returns a store that provides an access to our database.

func (*Store) AddAccountCertificates

func (st *Store) AddAccountCertificates(ctx context.Context, msg *types.MsgAddAccountCertificates) (int64, error)

func (*Store) DeleteAccount

func (st *Store) DeleteAccount(ctx context.Context, msg *types.MsgDeleteAccount) error

func (*Store) DeleteAccountCerts

func (st *Store) DeleteAccountCerts(ctx context.Context, msg *types.MsgDeleteAccountCertificate) error

func (*Store) DeleteDomain

func (st *Store) DeleteDomain(ctx context.Context, msg *types.MsgDeleteDomain) error

func (*Store) InsertBlock

func (st *Store) InsertBlock(ctx context.Context, b Block) error

func (*Store) InsertGenesis

func (st *Store) InsertGenesis(ctx context.Context, tmc *TendermintClient) error

func (*Store) LastNBlock

func (st *Store) LastNBlock(ctx context.Context, limit, after int) ([]*Block, error)

func (*Store) LatestBlock

func (st *Store) LatestBlock(ctx context.Context) (*Block, error)

func (*Store) RegisterAccount

func (st *Store) RegisterAccount(ctx context.Context, msg *types.MsgRegisterAccount) (int64, error)

func (*Store) RegisterDomain

func (st *Store) RegisterDomain(ctx context.Context, msg *types.MsgRegisterDomain) (int64, error)

func (*Store) ReplaceAccountMetadata

func (st *Store) ReplaceAccountMetadata(ctx context.Context, msg *types.MsgReplaceAccountMetadata) error

func (*Store) ReplaceAccountResources

func (st *Store) ReplaceAccountResources(ctx context.Context, msg *types.MsgReplaceAccountResources) (int64, error)

func (*Store) TransferAccount

func (st *Store) TransferAccount(ctx context.Context, msg *types.MsgTransferAccount) error

func (*Store) TransferDomain

func (st *Store) TransferDomain(ctx context.Context, msg *types.MsgTransferDomain) error

type TendermintBlock

type TendermintBlock struct {
	Height            int64
	Time              time.Time
	Transactions      []*auth.StdTx
	TransactionHashes [][32]byte
}

func FetchBlock

func FetchBlock(ctx context.Context, c *TendermintClient, height int64) (*TendermintBlock, error)

type TendermintClient

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

func DialTendermint

func DialTendermint(websocketURL string) (*TendermintClient, error)

DialTendermint returns a client that is maintains a websocket connection to tendermint API. The websocket is used instead of standard HTTP connection to lower the latency, bypass throttling and to allow subscription requests.

func (*TendermintClient) Close

func (c *TendermintClient) Close() error

func (*TendermintClient) Do

func (c *TendermintClient) Do(method string, dest interface{}, args ...interface{}) error

Do makes a jsonrpc call. This method is safe for concurrent calls.

Use API as described in https://tendermint.com/rpc/

type TendermintCommit

type TendermintCommit struct {
	Height               int64
	Hash                 []byte
	Time                 time.Time
	ProposerAddress      []byte
	ValidatorsHash       []byte
	ParticipantAddresses [][]byte
}

func Commit

func Commit(ctx context.Context, c *TendermintClient, height int64) (*TendermintCommit, error)

Jump to

Keyboard shortcuts

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