hub

package
v0.0.0-...-d87c5bd Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatesData

type AggregatesData struct {
	TotalsPerDay   []Totals `json:"totalsPerDay"`
	TotalsPerHour  []Totals `json:"totalsPerHour"`
	TotalsPerMonth []Totals `json:"totalsPerMonth"`
}

ClientData type represents the data that the server sends at every new block.

type BaseFeePercentiles

type BaseFeePercentiles struct {
	Maximum   uint `json:"Maximum"`
	Median    uint `json:"Median"`
	Minimum   uint `json:"Minimum"`
	Ninetieth uint `json:"ninetieth"`
}

type Block

type Block struct {
	BaseFeePerGas    string        `json:"baseFeePerGas"`
	Difficulty       string        `json:"difficulty"`
	ExtraData        string        `json:"extraData"`
	GasLimit         string        `json:"gasLimit"`
	GasUsed          string        `json:"gasUsed"`
	Hash             string        `json:"hash"`
	LogsBloom        string        `json:"logsBloom"`
	Miner            string        `json:"miner"`
	MixHash          string        `json:"mixHash"`
	Nonce            string        `json:"nonce"`
	Number           string        `json:"number"`
	ParentHash       string        `json:"parentHash"`
	ReceiptsRoot     string        `json:"receiptsRoot"`
	Sha3Uncles       string        `json:"sha3Uncles"`
	Size             string        `json:"size"`
	StateRoot        string        `json:"stateRoot"`
	Timestamp        string        `json:"timestamp"`
	TotalDifficulty  string        `json:"totalDifficulty"`
	Transactions     []string      `json:"transactions"`
	TransactionsRoot string        `json:"transactionsRoot"`
	Uncles           []interface{} `json:"uncles"`
}

Block type represents a single ethereum Block.

type BlockData

type BlockData struct {
	BaseFeeNext string         `json:"baseFeeNext"`
	Block       sql.BlockStats `json:"block"`
	Clients     int16          `json:"clients"`
	Totals      Totals         `json:"totals"`
	TotalsDay   Totals         `json:"totalsDay"`
	TotalsHour  Totals         `json:"totalsHour"`
	TotalsMonth Totals         `json:"totalsMonth"`
	TotalsWeek  Totals         `json:"totalsWeek"`
	Version     string         `json:"version"`
	USDPrice    float64        `json:"usdPrice"`
}

ClientData type represents the data that the server sends at every new block.

type Client

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

Client is a middleman between the websocket connection and the hub.

func NewClient

func NewClient(
	hub *Hub,
	conn *websocket.Conn,
) *Client

NewClient creates a new client.

type CoinbaseSpotResponse

type CoinbaseSpotResponse struct {
	Data struct {
		Base     string `json:"base"`
		Amount   string `json:"amount"`
		Currency string `json:"currency"`
	}
}

type HTTPClient

type HTTPClient interface {
	Do(request *http.Request) (*http.Response, error)
}

HTTPClient is an interface for making HTTP requests

type Health

type Health struct {
	Status string `json:"status"`
	Blocks int    `json:"blocks`
}

type Hub

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

Hub maintains the set of active clients and subscriptions messages to the clients.

func New

func New(
	debug bool,
	development bool,
	gethEndpointHTTP string,
	gethEndpointWebsocket string,
	dbPath string,
	ropsten bool,
	workerCount int,
) (*Hub, error)

New initializes a Hub instance.

func (*Hub) ListenAndServe

func (h *Hub) ListenAndServe(addr string) error

ListenAndServe serves the hub on the given network address.

type InitialData

type InitialData struct {
	Blocks      []sql.BlockStats `json:"blocks"`
	Clients     int16            `json:"clients"`
	Totals      Totals           `json:"totals"`
	TotalsDay   Totals           `json:"totalsDay"`
	TotalsHour  Totals           `json:"totalsHour"`
	TotalsMonth Totals           `json:"totalsMonth"`
	TotalsWeek  Totals           `json:"totalsWeek"`
	BlockNumber uint64           `json:"blockNumber"`
	Version     string           `json:"version"`
	USDPrice    float64          `json:"usdPrice"`
}

InitialData type represents the initial data that the client requests.

type LatestBlock

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

LatestBlock defines a mutexed block number

type LatestBlocks

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

LatestBlocks defines a mutexed list of latest blocks

type RPCClient

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

RPCClient is a client for the RPC interface

func (*RPCClient) CallContext

func (c *RPCClient) CallContext(
	version string,
	method string,
	blockNumber string,
	updateCache bool,
	args ...interface{},
) (json.RawMessage, error)

CallContext is a context for a single RPC call

type Stats

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

type Syncing

type Syncing struct {
	CurrentBlock string `json:"currentBlock"`
	HighestBlock string `json:"highestBlock"`
}

type Totals

type Totals struct {
	ID                 string             `json:"id"`
	BaseFee            uint               `json:"baseFee,omitempty"`
	BaseFeePercentiles BaseFeePercentiles `json:"baseFeePercentiles,omitempty"`
	Burned             string             `json:"burned"`
	Duration           uint64             `json:"duration"`
	Issuance           string             `json:"issuance"`
	Rewards            string             `json:"rewards"`
	Tips               string             `json:"tips"`
}

Totals type represents a single aggregate of all the data.

type TotalsList

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

TotalsList defines a mutexed list of latest totals

type TransactionLog

type TransactionLog struct {
	Address          string   `json:"address"`
	Topics           []string `json:"topics"`
	Data             string   `json:"data"`
	BlockNumber      string   `json:"blockNumber"`
	TransactionHash  string   `json:"transactionHash"`
	TransactionIndex string   `json:"transactionIndex"`
	BlockHash        string   `json:"blockHash"`
	LogIndex         string   `json:"logIndex"`
	Removed          bool     `json:"removed"`
}

TransactionLog type represents the transaction log.

type TransactionReceipt

type TransactionReceipt struct {
	BlockHash         string           `json:"blockHash"`
	BlockNumber       string           `json:"blockNumber"`
	ContractAddress   interface{}      `json:"contractAddress"`
	CumulativeGasUsed string           `json:"cumulativeGasUsed"`
	EffectiveGasPrice string           `json:"effectiveGasPrice"`
	From              string           `json:"from"`
	GasUsed           string           `json:"gasUsed"`
	Logs              []TransactionLog `json:"logs"`
	LogsBloom         string           `json:"logsBloom"`
	Status            string           `json:"status"`
	To                string           `json:"to"`
	TransactionHash   string           `json:"transactionHash"`
	TransactionIndex  string           `json:"transactionIndex"`
	Type              string           `json:"type"`
}

TransactionReceipt type represents a single ethereum Transaction.

type TransactionReceiptWorker

type TransactionReceiptWorker struct {
	NumWorkers int
	Endpoint   string
	// contains filtered or unexported fields
}

func (*TransactionReceiptWorker) Initialize

func (h *TransactionReceiptWorker) Initialize()

func (*TransactionReceiptWorker) QueueJob

func (h *TransactionReceiptWorker) QueueJob(transactions []string, blockNumber uint64, baseFee *big.Int, updateCache bool) ([]uint64, *big.Int, *big.Int, *big.Int)

type USDPriceWatcher

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

func (*USDPriceWatcher) GetPrice

func (u *USDPriceWatcher) GetPrice() float64

func (*USDPriceWatcher) StartWatching

func (u *USDPriceWatcher) StartWatching()

Jump to

Keyboard shortcuts

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