Documentation ¶
Overview ¶
chunksPkg implements the chifra chunks command.
The chifra chunks routine provides tools for interacting with, checking the validity of, cleaning up, and analyzing the Unchained Index. It provides options to list pins, the Manifest, summary data on the index, Bloom filters, addresses, and appearances. While still in its early stages, this tool will eventually allow users to clean their local index, clean their remote index, study the indexes, etc. Stay tuned.
Index ¶
- func GetChunkStats(chain, path string) (s types.ChunkStats, err error)
- func ResetOptions(testMode bool)
- func RunChunks(cmd *cobra.Command, args []string) error
- func ServeChunks(w http.ResponseWriter, r *http.Request) error
- type ChunksOptions
- func (opts *ChunksOptions) CheckDeep(cacheMan *manifest.Manifest, report *types.ReportCheck) error
- func (opts *ChunksOptions) CheckHashes(cacheMan *manifest.Manifest, contractMan *manifest.Manifest, ...) error
- func (opts *ChunksOptions) CheckInternal(fileNames []string, blockNums []base.Blknum, report *types.ReportCheck) error
- func (opts *ChunksOptions) CheckManContents(man *manifest.Manifest, report *types.ReportCheck) error
- func (opts *ChunksOptions) CheckManifest(arrayA, arrayB []string, report *types.ReportCheck) error
- func (opts *ChunksOptions) CheckSequential(fnArray, cacheArray, remoteArray []string, allowMissing bool, ...) error
- func (opts *ChunksOptions) CheckSizes(fileNames []string, blockNums []base.Blknum, cacheManifest *manifest.Manifest, ...) error
- func (opts *ChunksOptions) CheckStaging(lastBlock uint64, allow_missing bool, report *types.ReportCheck) error
- func (opts *ChunksOptions) CheckVersion(fileNames []string, blockNums []base.Blknum, report *types.ReportCheck) error
- func (opts *ChunksOptions) ChunksInternal(rCtx *output.RenderCtx) error
- func (opts *ChunksOptions) HandleAddresses(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleAppearances(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleBlooms(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleCheck(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleCounts(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleDiff(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleDump(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleIndex(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleIndexBelongs(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleList(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleManifest(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandlePin(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandlePublish(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleShow(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleStats(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleTag(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleTruncate(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) HandleUnpin(rCtx *output.RenderCtx, blockNums []base.Blknum) error
- func (opts *ChunksOptions) String() string
- type CompareState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetChunkStats ¶
func GetChunkStats(chain, path string) (s types.ChunkStats, err error)
func ResetOptions ¶
func ResetOptions(testMode bool)
func RunChunks ¶
RunChunks handles the chunks command for the command line. Returns error only as per cobra.
func ServeChunks ¶
func ServeChunks(w http.ResponseWriter, r *http.Request) error
ServeChunks handles the chunks command for the API. Returns an error.
Types ¶
type ChunksOptions ¶
type ChunksOptions struct { Mode string `json:"mode,omitempty"` // The type of data to process Blocks []string `json:"blocks,omitempty"` // An optional list of blocks to intersect with chunk ranges BlockIds []identifiers.Identifier `json:"blockIds,omitempty"` // Block identifiers Check bool `json:"check,omitempty"` // Check the manifest, index, or blooms for internal consistency Pin bool `json:"pin,omitempty"` // Pin the manifest or each index chunk and bloom Publish bool `json:"publish,omitempty"` // Publish the manifest to the Unchained Index smart contract Publisher string `json:"publisher,omitempty"` // For some query options, the publisher of the index Truncate base.Blknum `json:"truncate,omitempty"` // Truncate the entire index at this block (requires a block identifier) Remote bool `json:"remote,omitempty"` // Prior to processing, retrieve the manifest from the Unchained Index smart contract Belongs []string `json:"belongs,omitempty"` // In index mode only, checks the address(es) for inclusion in the given index chunk Diff bool `json:"diff,omitempty"` // Compare two index portions (see notes) FirstBlock base.Blknum `json:"firstBlock,omitempty"` // First block to process (inclusive) LastBlock base.Blknum `json:"lastBlock,omitempty"` // Last block to process (inclusive) MaxAddrs uint64 `json:"maxAddrs,omitempty"` // The max number of addresses to process in a given chunk Deep bool `json:"deep,omitempty"` // If true, dig more deeply during checking (manifest only) Rewrite bool `json:"rewrite,omitempty"` // For the --pin --deep mode only, writes the manifest back to the index folder (see notes) List bool `json:"list,omitempty"` // For the pins mode only, list the remote pins Unpin bool `json:"unpin,omitempty"` // For the pins mode only, if true reads local ./unpins file for valid CIDs and remotely unpins each (skips non-CIDs) Count bool `json:"count,omitempty"` // For certain modes only, display the count of records Tag string `json:"tag,omitempty"` // Visits each chunk and updates the headers with the supplied version string (vX.Y.Z-str) Sleep float64 `json:"sleep,omitempty"` // For --remote pinning only, seconds to sleep between API calls 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:"-"` }
ChunksOptions provides all command options for the chifra chunks command.
func ChunksFinishParseInternal ¶
func ChunksFinishParseInternal(w io.Writer, values url.Values) *ChunksOptions
func GetChunksOptions ¶
func GetChunksOptions(args []string, g *globals.GlobalOptions) *ChunksOptions
GetChunksOptions returns the options for this tool so other tools may use it.
func GetOptions ¶
func GetOptions() *ChunksOptions
func (*ChunksOptions) CheckDeep ¶
func (opts *ChunksOptions) CheckDeep(cacheMan *manifest.Manifest, report *types.ReportCheck) error
CheckDeep digs deep into the data. In `index` mode, it opens each index and checks that all addresses in the index return true when checked against its corresponding Bloom filter. In `manifest` mode, it checks that each IPFS hash in the manifest is actually pinned. The later requires a locally running IPFS node.
func (*ChunksOptions) CheckHashes ¶
func (opts *ChunksOptions) CheckHashes(cacheMan *manifest.Manifest, contractMan *manifest.Manifest, report *types.ReportCheck) error
CheckHashes looks at all the hashes in both the locally cached manifest and the manifest retrieved from the smart contract and simply checks the lengths of the bloom and index IPFS hashes.
func (*ChunksOptions) CheckInternal ¶
func (opts *ChunksOptions) CheckInternal(fileNames []string, blockNums []base.Blknum, report *types.ReportCheck) error
CheckInternal reads the header of each chunk on disc looking for the Magic number and the hash of the spec version for expected values.
func (*ChunksOptions) CheckManContents ¶
func (opts *ChunksOptions) CheckManContents(man *manifest.Manifest, report *types.ReportCheck) error
CheckManContents spins through the manifest and makes sure all the bloom and index CIDs are present. It does not check that the CIDs are available.
func (*ChunksOptions) CheckManifest ¶
func (opts *ChunksOptions) CheckManifest(arrayA, arrayB []string, report *types.ReportCheck) error
CheckManifest takes two arrays (either onDisc vs. LocalManifest, onDisc vs. RemoteManifest, or LocalManifest vs. RemoteManifest) and compares them for equality. If everything is up to date, all three arrays should be identical. Only the block ranges are in the arrays.
func (*ChunksOptions) CheckSequential ¶
func (opts *ChunksOptions) CheckSequential(fnArray, cacheArray, remoteArray []string, allowMissing bool, report *types.ReportCheck) error
CheckSequential checks that the range of blocks in each of three arrays (onDisc, LocalManifest, RemoteManifest) "cover" the range without gaps. (There may be a bug for allow_missing chains where gaps are allowed.) It also makes sure than snap-to-grids happen where they should and that non-snaps have at least appsPerChunks records and snaps have exactly appsPerChunks records or less.
func (*ChunksOptions) CheckSizes ¶
func (opts *ChunksOptions) CheckSizes(fileNames []string, blockNums []base.Blknum, cacheManifest *manifest.Manifest, remoteManifest *manifest.Manifest, report *types.ReportCheck) error
CheckSizes compares the file on disc to the file size suggested in the manifest
func (*ChunksOptions) CheckStaging ¶
func (opts *ChunksOptions) CheckStaging(lastBlock uint64, allow_missing bool, report *types.ReportCheck) error
CheckStaging checks the staging file which should be names first-second.txt
- Makes sure that finalized + 1 == first
- Makes sure the first < last
- Makes sure that the first block inside is == first if allow_missing == false, > otherwise
- Makes sure that the last block inside is == last if allow_missing == false, < otherwise
func (*ChunksOptions) CheckVersion ¶
func (opts *ChunksOptions) CheckVersion(fileNames []string, blockNums []base.Blknum, report *types.ReportCheck) error
CheckVersion reads the header of each chunk on disc looking for the Magic number and the hash of the spec version for expected values.
func (*ChunksOptions) ChunksInternal ¶
func (opts *ChunksOptions) ChunksInternal(rCtx *output.RenderCtx) error
ChunksInternal handles the internal workings of the chunks command. Returns an error.
func (*ChunksOptions) HandleAddresses ¶
func (*ChunksOptions) HandleAppearances ¶
func (*ChunksOptions) HandleBlooms ¶
func (*ChunksOptions) HandleCheck ¶
HandleCheck looks at three different arrays: index files on disc, manifest on disc, and manifest in the smart contract. It tries to check these three sources for cosnsistency. Smart contract rules, so it is checked more thoroughly.
func (*ChunksOptions) HandleCounts ¶
func (*ChunksOptions) HandleDiff ¶
func (*ChunksOptions) HandleDump ¶
func (*ChunksOptions) HandleIndex ¶
func (*ChunksOptions) HandleIndexBelongs ¶
func (opts *ChunksOptions) HandleIndexBelongs(rCtx *output.RenderCtx, blockNums []base.Blknum) error
HandleIndexBelongs displays the resolved records in a chunk given a single address
func (*ChunksOptions) HandleList ¶
func (*ChunksOptions) HandleManifest ¶
func (*ChunksOptions) HandlePublish ¶
func (*ChunksOptions) HandleShow ¶
func (*ChunksOptions) HandleStats ¶
func (*ChunksOptions) HandleTruncate ¶
func (*ChunksOptions) HandleUnpin ¶
func (*ChunksOptions) String ¶
func (opts *ChunksOptions) String() string
String implements the Stringer interface
type CompareState ¶
type CompareState struct {
// contains filtered or unexported fields
}
Source Files ¶
- doc.go
- handle_address.go
- handle_appearances.go
- handle_blooms.go
- handle_check.go
- handle_check_deep.go
- handle_check_hashes.go
- handle_check_internal.go
- handle_check_manifest.go
- handle_check_sequential.go
- handle_check_sizes.go
- handle_check_staging.go
- handle_check_version.go
- handle_counts.go
- handle_diff.go
- handle_dump.go
- handle_index.go
- handle_index_belongs.go
- handle_list.go
- handle_manifest.go
- handle_pin.go
- handle_publish.go
- handle_show.go
- handle_stats.go
- handle_tag.go
- handle_truncate.go
- handle_unpin.go
- options.go
- output.go
- validate.go