top_senders

package module
v0.0.0-...-17acc08 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 10 Imported by: 0

README

topsenders

This is a simple utility that shows the account and type of transactions for a range of blocks on a cosmos chain.

Limitations:

  • The API used is only available in cosmos-sdk v0.45.2 and later.
  • This doesn't use a TUI library and the screen is cleared with ansi resets which might not be pretty.
  • It uses periodic polling to get the latest blocks, so it might miss some blocks if the polling interval is too long.
  • It's likely that it won't know about some transaction types and will print the block number for those.

Installation

git clone https://github.com/blockpane/topsenders.git
cd topsenders/
go install ./...

Usage

Usage of topsenders
  -api string
    	REQUIRED: API URL, ex: http://localhost:1317
  -blocks int
    	optional: max number of blocks to show (default 100)
  -interval duration
    	optional: polling interval, ex: 2s, 250ms (default 2s)
  -rpc string
    	REQUIRED: RPC URL, ex: http://localhost:26657
  -top int
    	optional: how many top senders to show (default 20)

Example

$ topsenders -api http://injective:1317 -rpc http://injective:26657 -top 10 -interval 250ms

screen shot

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ApiURL   string
	RpcUrl   string
	Interval time.Duration
	LookBack int
	Top      int
)

Functions

func CombineCountTables

func CombineCountTables(countTables []map[string]map[string]int) map[string]map[string]int

CombineCountTables will combine multiple count tables into a single count table

func CountMessageTypeBySender

func CountMessageTypeBySender(root Root, height string) (countTable map[string]map[string]int)

CountMessageTypeBySender will return a map of sender addresses to a map of message types to counts

func GetBlockHeight

func GetBlockHeight(url string) (height, network string, err error)

GetBlockHeight will retrieve the height from the /status endpoint

func Txs

func Txs()

Types

type Message

type Message struct {
	Type string `json:"@type"`

	Sender           string `json:"sender"`
	Voter            string `json:"voter"`
	Delegator        string `json:"delegator_address"`
	Grantee          string `json:"grantee"`
	FromAddress      string `json:"from_address"`
	Signer           string `json:"signer"`
	Creator          string `json:"creator"`
	ValidatorAddress string `json:"validator_address"`
	CosmosReceiver   string `json:"cosmos_receiver"`
	From             string `json:"from"`
	Requester        string `json:"requester"`
	Initiator        string `json:"initiator"`
	Depositor        string `json:"depositor"`
	Orchestrator     string `json:"orchestrator"`
	Trader           string `json:"trader"`
}

Message is a combination of the various message types we're interested in since each message might have different fields for the sender, we add them all and just concatenate them together in CountMessageTypeBySender

type Root

type Root struct {
	Txs []Tx `json:"txs"`
}

func GetTxs

func GetTxs(url, height string) (root Root, err error)

GetTxs will retrieve the txs from the /cosmos/tx/v1beta1/txs/block/<height> endpoint and return a Root struct

type Status

type Status struct {
	Result struct {
		NodeInfo struct {
			Network string `json:"network"`
		} `json:"node_info"`
		SyncInfo struct {
			LatestBlockHeight string `json:"latest_block_height"`
		} `json:"sync_info"`
	} `json:"result"`
}

func (Status) Height

func (s Status) Height() string

type Tx

type Tx struct {
	Body struct {
		Messages []Message `json:"messages"`
	} `json:"body"`
}

Directories

Path Synopsis
cmd
topsenders command

Jump to

Keyboard shortcuts

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