initPkg

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

README

chifra init

When invoked, chifra init reads a value from a smart contract called The Unchained Index (0x0c316b7042b419d07d343f2f4f5bd54ff731183d).

This value (manifestHashMap) is an IPFS hash pointing to a pinned file (called the Manifest) that contains a large collection of other IPFS hashes. These other hashes point to each of the Bloom filter and Index Chunk. TrueBlocks periodically publishes the Manifest's hash to the smart contract. This makes the index available for our software to use and impossible for us to withhold. Both of these aspects of the manifest are by design.

If you stop chifra init before it finishes, it will pick up again where it left off the next time you run it.

Certain parts of the system (chifra list and chifra export for example) if you have not previously run chifra init or chifra scrape. You will be warned by the system until it's satisfied.

If you run chifra init and allow it to complete, the next time you run chifra scrape, it will start where init finished. This means that only the blooms will be stored on your hard drive. Subsequent scraping will produce both chunks and blooms, although you can, if you wish delete chunks that are not being used. You may periodically run chifra init if you prefer not to scrape.

Purpose:
  Initialize the TrueBlocks system by downloading the Unchained Index from IPFS.

Usage:
  chifra init [flags]

Flags:
  -a, --all                in addition to Bloom filters, download full index chunks (recommended)
  -d, --dry_run            display the results of the download without actually downloading
  -F, --first_block uint   do not download any chunks earlier than this block
  -s, --sleep float        seconds to sleep between downloads
  -v, --verbose            enable verbose output
  -h, --help               display this help screen

Notes:
  - If run with no options, this tool will download or freshen only the Bloom filters.
  - The --first_block option will fall back to the start of the containing chunk.
  - You may re-run the tool as often as you wish. It will repair or freshen the index.

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 initPkg handles the chifra init command. It When invoked, reads a value from a smart contract called **The Unchained Index** (0x0c316b7042b419d07d343f2f4f5bd54ff731183d). This value (manifestHashMap) is an IPFS hash pointing to a pinned file (called the Manifest) that contains a large collection of other IPFS hashes. These other hashes point to each of the Bloom filter and Index Chunk. TrueBlocks periodically publishes the Manifest's hash to the smart contract. This makes the index available for our software to use and impossible for us to withhold. Both of these aspects of the manifest are by design. If you stop chifra init before it finishes, it will pick up again where it left off the next time you run it. Certain parts of the system (chifra list and chifra export for example) if you have not previously run chifra init or chifra scrape. You will be warned by the system until it's satisfied. If you run chifra init and allow it to complete, the next time you run chifra scrape, it will start where init finished. This means that only the blooms will be stored on your hard drive. Subsequent scraping will produce both chunks and blooms, although you can, if you wish delete chunks that are not being used. You may periodically run chifra init if you prefer not to scrape.

Index

Constants

This section is empty.

Variables

View Source
var Reasons = map[InitReason]string{
	OKAY:            "okay",
	FILE_ERROR:      "file error",
	FILE_MISSING:    "file missing",
	WRONG_SIZE:      "wrong size",
	WRONG_MAGIC:     "wrong magic number",
	WRONG_HASH:      "wrong header hash",
	NOT_IN_MANIFEST: "not in manifest",
	AFTER_MANIFEST:  "range after manifest",
}

Functions

func ResetOptions

func ResetOptions(testMode bool)

func RunInit

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

RunInit handles the init command for the command line. Returns error only as per cobra.

func ServeInit

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

ServeInit handles the init command for the API. Returns an error.

Types

type InitOptions

type InitOptions struct {
	All        bool                  `json:"all,omitempty"`        // In addition to Bloom filters, download full index chunks (recommended)
	DryRun     bool                  `json:"dryRun,omitempty"`     // Display the results of the download without actually downloading
	Publisher  string                `json:"publisher,omitempty"`  // The publisher of the index to download
	FirstBlock uint64                `json:"firstBlock,omitempty"` // Do not download any chunks earlier than this block
	Sleep      float64               `json:"sleep,omitempty"`      // Seconds to sleep between downloads
	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
	// EXISTING_CODE
	PublisherAddr base.Address `json:"-"`
}

InitOptions provides all command options for the chifra init command.

func GetInitOptions

func GetInitOptions(args []string, g *globals.GlobalOptions) *InitOptions

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

func GetOptions

func GetOptions() *InitOptions

func (*InitOptions) HandleDryRun

func (opts *InitOptions) HandleDryRun() error

func (*InitOptions) HandleInit

func (opts *InitOptions) HandleInit() error

HandleInit initializes local copy of UnchainedIndex by downloading manifests and chunks

func (*InitOptions) InitInternal

func (opts *InitOptions) InitInternal() error

InitInternal handles the internal workings of the init command. Returns an error.

func (*InitOptions) String

func (opts *InitOptions) String() string

String implements the Stringer interface

type InitReason

type InitReason int
const (
	OKAY InitReason = iota
	FILE_MISSING
	WRONG_SIZE
	WRONG_MAGIC
	WRONG_HASH
	FILE_ERROR
	NOT_IN_MANIFEST
	AFTER_MANIFEST
)

Jump to

Keyboard shortcuts

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