-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3886 from TrueBlocks/feature/indexManager
Adds a devtool to check disc usage on various computers
- Loading branch information
Showing
15 changed files
with
551 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ SymbolCache.noindex | |
|
||
chifra* | ||
goMaker | ||
indexManager | ||
sdkFuzzer | ||
makeClass | ||
testRunner | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,10 @@ import ( | |
"fmt" | ||
"strings" | ||
|
||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/manifest" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" | ||
"github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/version" | ||
) | ||
|
||
type CompareState struct { | ||
|
@@ -22,9 +25,9 @@ type CompareState struct { | |
// failB int | ||
} | ||
|
||
// 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. | ||
// 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 (opts *ChunksOptions) CheckManifest(arrayA, arrayB []string, report *types.ReportCheck) error { | ||
comp := CompareState{ | ||
testMode: opts.Globals.TestMode, | ||
|
@@ -46,7 +49,6 @@ func (opts *ChunksOptions) CheckManifest(arrayA, arrayB []string, report *types. | |
return comp.checkArrays(report) | ||
} | ||
|
||
// TODO: Can this be made concurrent? | ||
func (comp *CompareState) checkArrays(report *types.ReportCheck) error { | ||
marker := "" | ||
if comp.testMode { | ||
|
@@ -96,3 +98,70 @@ func (comp *CompareState) checkArrays(report *types.ReportCheck) error { | |
|
||
return nil | ||
} | ||
|
||
// 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 (opts *ChunksOptions) CheckManContents(man *manifest.Manifest, report *types.ReportCheck) error { | ||
errs := []string{} | ||
|
||
report.VisitedCnt += 3 | ||
report.CheckedCnt += 3 | ||
|
||
if !version.IsValidVersion(man.Version) { | ||
errs = append(errs, "invalid version string "+opts.Tag) | ||
} else { | ||
report.PassedCnt++ | ||
} | ||
|
||
if opts.Globals.Chain != man.Chain { | ||
errs = append(errs, "different chains: globals("+opts.Globals.Chain+") manifest ("+man.Chain+")") | ||
} else { | ||
report.PassedCnt++ | ||
} | ||
|
||
expectedSpec := config.SpecTags["[email protected]"] | ||
if expectedSpec != man.Specification.String() { | ||
errs = append(errs, "invalid spec "+man.Specification.String()) | ||
} else { | ||
report.PassedCnt++ | ||
} | ||
|
||
for _, chunk := range man.Chunks { | ||
report.VisitedCnt++ | ||
report.CheckedCnt++ | ||
if len(chunk.Range) == 0 { | ||
errs = append(errs, "empty range") | ||
} else { | ||
report.PassedCnt++ | ||
} | ||
|
||
report.VisitedCnt++ | ||
report.CheckedCnt++ | ||
hasBloom := len(chunk.BloomHash) > 0 | ||
hasIndex := len(chunk.IndexHash) > 0 | ||
bloomSize := chunk.BloomSize > 0 | ||
indexSize := chunk.IndexSize > 0 | ||
if hasBloom && hasIndex && bloomSize && indexSize { | ||
report.PassedCnt++ | ||
} else { | ||
if !hasBloom { | ||
errs = append(errs, chunk.Range+" - missing bloom hash") | ||
} | ||
if !hasIndex { | ||
errs = append(errs, chunk.Range+" - missing index hash") | ||
} | ||
if !bloomSize { | ||
errs = append(errs, chunk.Range+" - missing bloom size") | ||
} | ||
if !indexSize { | ||
errs = append(errs, chunk.Range+" - missing index size") | ||
} | ||
} | ||
} | ||
|
||
if len(errs) > 0 { | ||
report.MsgStrings = append(report.MsgStrings, errs...) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
disc_usage_report.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# indexManager | ||
|
||
The `indexManager` tool is for internal use only. |
Oops, something went wrong.