pkg

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 28 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 EnsureDatabase added in v0.9.7

func EnsureDatabase(user, password, host, database, ssl string) error

func EnsureSchema

func EnsureSchema(pg *sql.DB, database, rouser, ropassword string) error

func FetchLcdData added in v0.9.7

func FetchLcdData(ctx context.Context, urlLCD string, queries *[]*LcdRequestData, height int64) (*[]*LcdResponseData, error)

func Sync

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

Sync uploads to local store all blocks that are not present yet, starting with the blocks with the lowest height 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 {
	// database
	DBHost string
	DBName string
	DBSSL  string
	// Read-write user
	DBUser string
	DBPass string
	// Read-only user
	DBROUser string
	DBROPass string
	// Denomination of the fee coin, eg uiov
	FeeDenom string
	// Tendermint light client daemon URL
	TendermintLcdUrl string
	// Tendermint websocket URI
	TendermintWsURI string
}

type LcdRequestData added in v0.9.7

type LcdRequestData struct {
	// accounts.id
	AccountID int64
	// URL encoded parameters to narrow the query on /txs as much as possible
	Params map[string]string
}

LcdRequestData is the data required to populate the product_fees table

type LcdResponseData added in v0.9.7

type LcdResponseData struct {
	TxResponse       *types.TxResponse
	TxError          *error
	StarnameResponse *StarnameResponse
	StarnameError    *error
}

type QueryError

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

func (*QueryError) Error

func (e *QueryError) Error() string

type StarnameResponse added in v0.9.7

type StarnameResponse struct {
	Height string `json:"height"`
	Result struct {
		Account starnametypes.Account `json:"account"`
	} `json:"result"`
}

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, height int64) (int64, error)

func (*Store) BatchBegin added in v0.9.7

func (st *Store) BatchBegin(ctx context.Context) error

func (*Store) BatchCommit added in v0.9.7

func (st *Store) BatchCommit(ctx context.Context) error

func (*Store) BatchRollback added in v0.9.7

func (st *Store) BatchRollback() error

func (*Store) DeleteAccount

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

func (*Store) DeleteAccountCerts

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

func (*Store) DeleteDomain

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

func (*Store) HandleLcdData added in v0.9.7

func (st *Store) HandleLcdData(ctx context.Context, queries *[]*LcdRequestData, responses *[]*LcdResponseData, height int64, denom string) 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, height int64) (int64, error)

func (*Store) RegisterDomain

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

func (*Store) RenewAccount added in v0.9.7

func (st *Store) RenewAccount(ctx context.Context, msg *types.MsgRenewAccount, height int64) (int64, error)

func (*Store) RenewDomain added in v0.9.7

func (st *Store) RenewDomain(ctx context.Context, msg *types.MsgRenewDomain, height int64) (int64, error)

func (*Store) ReplaceAccountMetadata

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

func (*Store) ReplaceAccountResources

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

func (*Store) TransferAccount

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

func (*Store) TransferDomain

func (st *Store) TransferDomain(ctx context.Context, msg *types.MsgTransferDomain, height int64) (int64, 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