exportPkg

package
v0.0.0-...-3f8eaf4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 33 Imported by: 0

README

chifra export

The chifra export tools provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, chifra export completes the actual extraction of an address's transactional history from the node.

You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results.

You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish.

By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you.

Purpose:
  Export full details of transactions for one or more addresses.

Usage:
  chifra export [flags] <address> [address...] [topics...] [fourbytes...]

Arguments:
  addrs - one or more addresses (0x...) to export (required)
  topics - filter by one or more log topics (only for --logs option)
  fourbytes - filter by one or more fourbytes (only for transactions and trace options)

Flags:
  -p, --appearances         export a list of appearances
  -r, --receipts            export receipts instead of transactional data
  -l, --logs                export logs instead of transactional data
  -t, --traces              export traces instead of transactional data
  -n, --neighbors           export the neighbors of the given address
  -C, --accounting          attach accounting records to the exported data (applies to transactions export only)
  -A, --statements          for the accounting options only, export only statements
  -b, --balances            traverse the transaction history and show each change in ETH balances
  -i, --withdrawals         export withdrawals for the given address
  -a, --articulate          articulate transactions, traces, logs, and outputs
  -R, --cache_traces        force the transaction's traces into the cache
  -U, --count               for --appearances mode only, display only the count of records
  -c, --first_record uint   the first record to process
  -e, --max_records uint    the maximum number of records to process (default 250)
  -N, --relevant            for log and accounting export only, export only logs relevant to one of the given export addresses
  -m, --emitter strings     for the --logs option only, filter logs to show only those logs emitted by the given address(es)
  -B, --topic strings       for the --logs option only, filter logs to show only those with this topic(s)
  -V, --reverted            export only transactions that were reverted
  -P, --asset strings       for the accounting options only, export statements only for this asset
  -f, --flow string         for the accounting options only, export statements with incoming, outgoing, or zero value
                            One of [ in | out | zero ]
  -y, --factory             for --traces only, report addresses created by (or self-destructed by) the given address(es)
  -u, --unripe              export transactions labeled upripe (i.e. less than 28 blocks old)
  -E, --reversed            produce results in reverse chronological order
  -z, --no_zero             for the --count option only, suppress the display of zero appearance accounts
  -F, --first_block uint    first block to process (inclusive)
  -L, --last_block uint     last block to process (inclusive)
  -H, --ether               specify value in ether
  -o, --cache               force the results of the query into the cache
  -D, --decache             removes related items from the cache
  -x, --fmt string          export format, one of [none|json*|txt|csv]
  -v, --verbose             enable verbose output
  -h, --help                display this help screen

Notes:
  - An address must be either an ENS name or start with '0x' and be forty-two characters long.
  - Articulating the export means turn the EVM's byte data into human-readable text (if possible).
  - For the --logs option, you may optionally specify one or more --emitter, one or more --topics, or both.
  - The --logs option is significantly faster if you provide an --emitter or a --topic.
  - Neighbors include every address that appears in any transaction in which the export address also appears.
  - If present, --first_/--last_block are applied, followed by user-supplied filters such as asset or topic, followed by --first_/--max_record if present.
  - The --first_record and --max_record options are zero-based (as are the block options).
  - The _block and _record filters are ignored when used with the --count option.
  - If the --reversed option is present, the appearance list is reversed prior to all processing (including filtering).
  - The --decache option will remove all cache items (blocks, transactions, traces, etc.) for the given address(es).
  - The --withdrawals option is only available on certain chains. It is ignored otherwise.

Data models produced by this tool:

Other Options

All tools accept the following additional flags, although in some cases, they have no meaning.

  -v, --version         display the current version of the tool
      --output string   write the results to file 'fn' and return the filename
      --append          for --output command only append to instead of replace contents of file
      --file string     specify multiple sets of command line options in a file

Note: For the --file string option, you may place a series of valid command lines in a file using any valid flags. In some cases, this may significantly improve performance. A semi-colon at the start of any line makes it a comment.

Note: If you use --output --append option and at the same time the --file option, you may not switch export formats in the command file. For example, a command file with two different commands, one with --fmt csv and the other with --fmt json will produce both invalid CSV and invalid JSON.

Documentation

Overview

Package exportPkg handles the chifra export command. It The tools provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, completes the actual extraction of an address's transactional history from the node. You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results. You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish. By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetOptions

func ResetOptions(testMode bool)

func RunExport

func RunExport(cmd *cobra.Command, args []string) error

RunExport handles the export command for the command line. Returns error only as per cobra.

func ServeExport

func ServeExport(w http.ResponseWriter, r *http.Request) error

ServeExport handles the export command for the API. Returns an error.

Types

type ExportOptions

type ExportOptions struct {
	Addrs       []string              `json:"addrs,omitempty"`       // One or more addresses (0x...) to export
	Topics      []string              `json:"topics,omitempty"`      // Filter by one or more log topics (only for --logs option)
	Fourbytes   []string              `json:"fourbytes,omitempty"`   // Filter by one or more fourbytes (only for transactions and trace options)
	Appearances bool                  `json:"appearances,omitempty"` // Export a list of appearances
	Receipts    bool                  `json:"receipts,omitempty"`    // Export receipts instead of transactional data
	Logs        bool                  `json:"logs,omitempty"`        // Export logs instead of transactional data
	Traces      bool                  `json:"traces,omitempty"`      // Export traces instead of transactional data
	Neighbors   bool                  `json:"neighbors,omitempty"`   // Export the neighbors of the given address
	Accounting  bool                  `json:"accounting,omitempty"`  // Attach accounting records to the exported data (applies to transactions export only)
	Statements  bool                  `json:"statements,omitempty"`  // For the accounting options only, export only statements
	Balances    bool                  `json:"balances,omitempty"`    // Traverse the transaction history and show each change in ETH balances
	Withdrawals bool                  `json:"withdrawals,omitempty"` // Export withdrawals for the given address
	Articulate  bool                  `json:"articulate,omitempty"`  // Articulate transactions, traces, logs, and outputs
	CacheTraces bool                  `json:"cacheTraces,omitempty"` // Force the transaction's traces into the cache
	Count       bool                  `json:"count,omitempty"`       // For --appearances mode only, display only the count of records
	FirstRecord uint64                `json:"firstRecord,omitempty"` // The first record to process
	MaxRecords  uint64                `json:"maxRecords,omitempty"`  // The maximum number of records to process
	Relevant    bool                  `json:"relevant,omitempty"`    // For log and accounting export only, export only logs relevant to one of the given export addresses
	Emitter     []string              `json:"emitter,omitempty"`     // For the --logs option only, filter logs to show only those logs emitted by the given address(es)
	Topic       []string              `json:"topic,omitempty"`       // For the --logs option only, filter logs to show only those with this topic(s)
	Reverted    bool                  `json:"reverted,omitempty"`    // Export only transactions that were reverted
	Asset       []string              `json:"asset,omitempty"`       // For the accounting options only, export statements only for this asset
	Flow        string                `json:"flow,omitempty"`        // For the accounting options only, export statements with incoming, outgoing, or zero value
	Factory     bool                  `json:"factory,omitempty"`     // For --traces only, report addresses created by (or self-destructed by) the given address(es)
	Unripe      bool                  `json:"unripe,omitempty"`      // Export transactions labeled upripe (i.e. less than 28 blocks old)
	Load        string                `json:"load,omitempty"`        // A comma separated list of dynamic traversers to load
	Reversed    bool                  `json:"reversed,omitempty"`    // Produce results in reverse chronological order
	NoZero      bool                  `json:"noZero,omitempty"`      // For the --count option only, suppress the display of zero appearance accounts
	FirstBlock  uint64                `json:"firstBlock,omitempty"`  // First block to process (inclusive)
	LastBlock   uint64                `json:"lastBlock,omitempty"`   // Last block to process (inclusive)
	Globals     globals.GlobalOptions `json:"globals,omitempty"`     // The global options
	Conn        *rpc.Connection       `json:"conn,omitempty"`        // The connection to the RPC server
	BadFlag     error                 `json:"badFlag,omitempty"`     // An error flag if needed

}

ExportOptions provides all command options for the chifra export command.

func GetExportOptions

func GetExportOptions(args []string, g *globals.GlobalOptions) *ExportOptions

GetExportOptions returns the options for this tool so other tools may use it.

func GetOptions

func GetOptions() *ExportOptions

func (*ExportOptions) ExportInternal

func (opts *ExportOptions) ExportInternal() error

ExportInternal handles the internal workings of the export command. Returns an error.

func (*ExportOptions) FreshenMonitorsForExport

func (opts *ExportOptions) FreshenMonitorsForExport(monitorArray *[]monitor.Monitor) (bool, error)

func (*ExportOptions) GetMax

func (opts *ExportOptions) GetMax() uint64

func (*ExportOptions) HandleAccounting

func (opts *ExportOptions) HandleAccounting(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleAppearances

func (opts *ExportOptions) HandleAppearances(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleBalances

func (opts *ExportOptions) HandleBalances(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleCount

func (opts *ExportOptions) HandleCount(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleDecache

func (opts *ExportOptions) HandleDecache(monitorArray []monitor.Monitor) error

HandleDecache handles the command chifra monitors --decache

func (*ExportOptions) HandleLogs

func (opts *ExportOptions) HandleLogs(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleNeighbors

func (opts *ExportOptions) HandleNeighbors(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleReceipts

func (opts *ExportOptions) HandleReceipts(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleShow

func (opts *ExportOptions) HandleShow(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleStatements

func (opts *ExportOptions) HandleStatements(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleTraces

func (opts *ExportOptions) HandleTraces(monitorArray []monitor.Monitor) error

func (*ExportOptions) HandleWithdrawals

func (opts *ExportOptions) HandleWithdrawals(monitorArray []monitor.Monitor) error

func (*ExportOptions) IsMax

func (opts *ExportOptions) IsMax(cnt uint64) bool

func (*ExportOptions) RemoveMonitor

func (opts *ExportOptions) RemoveMonitor(mon monitor.Monitor) string

func (*ExportOptions) String

func (opts *ExportOptions) String() string

String implements the Stringer interface

func (*ExportOptions) Validate

func (opts *ExportOptions) Validate() error

Validate calls into the opts validateExport routine

type Reason

type Reason struct {
	App     *types.SimpleAppearance
	Address *base.Address
	Reason  string
}

func GetNeighbors

func GetNeighbors(app *types.SimpleAppearance) ([]Reason, error)

Jump to

Keyboard shortcuts

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