whenPkg

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: 24 Imported by: 0

README

chifra when

The chifra when tool answers one of two questions: (1) "At what date and time did a given block occur?" or (2) "What block occurred at or before a given date and time?"

In the first case, supply a block number or hash and the date and time of that block are displayed. In the later case, supply a date (and optionally a time) and the block number that occurred at or just prior to that date is displayed.

The values for date and time are specified in JSON format. hour/minute/second are optional, and if omitted, default to zero in each case. Block numbers may be specified as either integers or hexadecimal number or block hashes. You may specify any number of dates and/or blocks per invocation.

Purpose:
  Find block(s) based on date, blockNum, timestamp, or 'special'.

Usage:
  chifra when [flags] < block | date > [ block... | date... ]

Arguments:
  blocks - one or more dates, block numbers, hashes, or special named blocks (see notes)

Flags:
  -l, --list         export a list of the 'special' blocks
  -t, --timestamps   display or process timestamps
  -U, --count        with --timestamps only, returns the number of timestamps in the cache
  -r, --repair       with --timestamps only, repairs block(s) in the block range by re-querying from the chain
  -c, --check        with --timestamps only, checks the validity of the timestamp data
  -u, --update       with --timestamps only, bring the timestamp database forward to the latest block
  -d, --deep         with --timestamps --check only, verifies timestamps from on chain (slow)
  -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:
  - The block list may contain any combination of number, hash, date, special named blocks.
  - Block numbers, timestamps, or dates in the future are estimated with 13 second blocks.
  - Dates must be formatted in JSON format: YYYY-MM-DD[THH[:MM[:SS]]].

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 whenPkg handles the chifra when command. It The tool answers one of two questions: (1) "At what date and time did a given block occur?" or (2) "What block occurred at or before a given date and time?" In the first case, supply a block number or hash and the date and time of that block are displayed. In the later case, supply a date (and optionally a time) and the block number that occurred at or just prior to that date is displayed. The values for date and time are specified in JSON format. hour/minute/second are optional, and if omitted, default to zero in each case. Block numbers may be specified as either integers or hexadecimal number or block hashes. You may specify any number of dates and/or blocks per invocation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetOptions

func ResetOptions(testMode bool)

func RunWhen

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

RunWhen handles the when command for the command line. Returns error only as per cobra.

func ServeWhen

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

ServeWhen handles the when command for the API. Returns an error.

Types

type WhenOptions

type WhenOptions struct {
	Blocks     []string                 `json:"blocks,omitempty"`     // One or more dates, block numbers, hashes, or special named blocks (see notes)
	BlockIds   []identifiers.Identifier `json:"blockIds,omitempty"`   // Block identifiers
	List       bool                     `json:"list,omitempty"`       // Export a list of the 'special' blocks
	Timestamps bool                     `json:"timestamps,omitempty"` // Display or process timestamps
	Count      bool                     `json:"count,omitempty"`      // With --timestamps only, returns the number of timestamps in the cache
	Truncate   uint64                   `json:"truncate,omitempty"`   // With --timestamps only, truncates the timestamp file at this block
	Repair     bool                     `json:"repair,omitempty"`     // With --timestamps only, repairs block(s) in the block range by re-querying from the chain
	Check      bool                     `json:"check,omitempty"`      // With --timestamps only, checks the validity of the timestamp data
	Update     bool                     `json:"update,omitempty"`     // With --timestamps only, bring the timestamp database forward to the latest block
	Deep       bool                     `json:"deep,omitempty"`       // With --timestamps --check only, verifies timestamps from on chain (slow)
	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

}

WhenOptions provides all command options for the chifra when command.

func GetOptions

func GetOptions() *WhenOptions

func GetWhenOptions

func GetWhenOptions(args []string, g *globals.GlobalOptions) *WhenOptions

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

func (*WhenOptions) HandleDecache

func (opts *WhenOptions) HandleDecache() error

func (*WhenOptions) HandleList

func (opts *WhenOptions) HandleList() error

func (*WhenOptions) HandleShow

func (opts *WhenOptions) HandleShow() error

func (*WhenOptions) HandleTimestampCount

func (opts *WhenOptions) HandleTimestampCount() error

func (*WhenOptions) HandleTimestampUpdate

func (opts *WhenOptions) HandleTimestampUpdate() error

HandleTimestampUpdate update the timestamp file to the latest block

func (*WhenOptions) HandleTimestampsCheck

func (opts *WhenOptions) HandleTimestampsCheck() error

HandleTimestampsCheck handles chifra when --timestamps --check

func (*WhenOptions) HandleTimestampsRepair

func (opts *WhenOptions) HandleTimestampsRepair() error

HandleTimestampsRepair handles chifra when --timestamps --reset <bn> to reset a single block's timestamps (call repeatedly if needed)

func (*WhenOptions) HandleTimestampsShow

func (opts *WhenOptions) HandleTimestampsShow() error

HandleTimestampsShow handles chifra when --timestamps

func (*WhenOptions) HandleTimestampsTruncate

func (opts *WhenOptions) HandleTimestampsTruncate() error

HandleTimestampsTruncate handles chifra when --timestamps --drop <bn>

func (*WhenOptions) String

func (opts *WhenOptions) String() string

String implements the Stringer interface

func (*WhenOptions) WhenInternal

func (opts *WhenOptions) WhenInternal() error

WhenInternal handles the internal workings of the when command. Returns an error.

Jump to

Keyboard shortcuts

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