Documentation
¶
Overview ¶
initPkg implements the chifra init command.
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.
Index ¶
- Variables
- func ResetOptions(testMode bool)
- func RunInit(cmd *cobra.Command, args []string) error
- func ServeInit(w http.ResponseWriter, r *http.Request) error
- type InitOptions
- func (opts *InitOptions) HandleDryRun(rCtx *output.RenderCtx) error
- func (opts *InitOptions) HandleExample(rCtx *output.RenderCtx) error
- func (opts *InitOptions) HandleInit(rCtx *output.RenderCtx) error
- func (opts *InitOptions) HandleShow(rCtx *output.RenderCtx) error
- func (opts *InitOptions) InitInternal(rCtx *output.RenderCtx) error
- func (opts *InitOptions) String() string
- type InitReason
Constants ¶
This section is empty.
Variables ¶
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)
Types ¶
type InitOptions ¶
type InitOptions struct {
All bool `json:"all,omitempty"` // In addition to Bloom filters, download full index chunks (recommended)
Example string `json:"example,omitempty"` // Create an example for the SDK with the given name
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 base.Blknum `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 InitFinishParseInternal ¶
func InitFinishParseInternal(w io.Writer, values url.Values) *InitOptions
func (*InitOptions) HandleDryRun ¶
func (opts *InitOptions) HandleDryRun(rCtx *output.RenderCtx) error
func (*InitOptions) HandleExample ¶
func (opts *InitOptions) HandleExample(rCtx *output.RenderCtx) error
HandleExample populates a subfolder of the ./examples folder with a skeleton of the files needed to run an example. This is a convenience function for developers to quickly get started with the example.
func (*InitOptions) HandleInit ¶
func (opts *InitOptions) HandleInit(rCtx *output.RenderCtx) error
HandleInit initializes local copy of UnchainedIndex by downloading manifests and chunks
func (*InitOptions) HandleShow ¶
func (opts *InitOptions) HandleShow(rCtx *output.RenderCtx) error
HandleShow initializes local copy of UnchainedIndex by downloading manifests and chunks
func (*InitOptions) InitInternal ¶
func (opts *InitOptions) InitInternal(rCtx *output.RenderCtx) 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 )