From 380daa92884899569887a6fd5cd4ce75aa761c0a Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 06:55:14 -0400 Subject: [PATCH 01/18] Adds Stringer interface to all types --- src/apps/chifra/internal/blocks/types_blockcount.go | 7 +++++++ src/apps/chifra/internal/chunks/types_chunkaddress.go | 7 +++++++ src/apps/chifra/internal/chunks/types_chunkbloom.go | 7 +++++++ src/apps/chifra/internal/chunks/types_chunkindex.go | 7 +++++++ .../chifra/internal/chunks/types_chunkpinreport.go | 7 +++++++ src/apps/chifra/internal/chunks/types_ipfspin.go | 6 ++++++ src/apps/chifra/internal/chunks/types_reportcheck.go | 11 ++++++++++- .../chifra/internal/monitors/types_monitorclean.go | 7 +++++++ src/apps/chifra/internal/status/types_cacheitem.go | 7 +++++++ src/apps/chifra/internal/status/types_status.go | 6 ++++++ src/apps/chifra/internal/traces/types_tracecount.go | 7 +++++++ src/apps/chifra/internal/when/types_timestamp.go | 7 +++++++ src/apps/chifra/internal/when/types_timestampcount.go | 11 ++++++++++- src/apps/chifra/pkg/types/types_abi.go | 7 +++++++ src/apps/chifra/pkg/types/types_appearance.go | 6 ++++++ src/apps/chifra/pkg/types/types_appearancecount.go | 11 ++++++++++- src/apps/chifra/pkg/types/types_block.go | 6 ++++++ src/apps/chifra/pkg/types/types_bounds.go | 6 ++++++ src/apps/chifra/pkg/types/types_chain.go | 6 ++++++ src/apps/chifra/pkg/types/types_chunkrecord.go | 10 +++++----- src/apps/chifra/pkg/types/types_chunkstats.go | 7 +++++++ src/apps/chifra/pkg/types/types_function.go | 5 +++++ src/apps/chifra/pkg/types/types_log.go | 6 ++++++ src/apps/chifra/pkg/types/types_logfilter.go | 7 +++++++ src/apps/chifra/pkg/types/types_manifest.go | 7 +++++++ src/apps/chifra/pkg/types/types_monitor.go | 7 +++++++ src/apps/chifra/pkg/types/types_name.go | 6 ++++++ src/apps/chifra/pkg/types/types_namedblock.go | 7 +++++++ src/apps/chifra/pkg/types/types_parameter.go | 5 +++++ src/apps/chifra/pkg/types/types_receipt.go | 6 ++++++ src/apps/chifra/pkg/types/types_result.go | 6 ++++++ src/apps/chifra/pkg/types/types_slurp.go | 6 ++++++ src/apps/chifra/pkg/types/types_state.go | 6 ++++++ src/apps/chifra/pkg/types/types_statement.go | 6 ++++++ src/apps/chifra/pkg/types/types_token.go | 7 +++++++ src/apps/chifra/pkg/types/types_trace.go | 6 ++++++ src/apps/chifra/pkg/types/types_traceaction.go | 6 ++++++ src/apps/chifra/pkg/types/types_tracefilter.go | 6 ++++++ src/apps/chifra/pkg/types/types_traceresult.go | 6 ++++++ src/apps/chifra/pkg/types/types_transaction.go | 6 ++++++ src/apps/chifra/pkg/types/types_withdrawal.go | 6 ++++++ .../src_apps_chifra_internal_route_types_type.go.tmpl | 5 +++++ .../templates/src_apps_chifra_pkg_types_type.go.tmpl | 5 +++++ test/gold/tools/ethslurp/ethslurp_help.txt | 2 +- test/gold/tools/ethslurp/ethslurp_help_long.txt | 2 +- 45 files changed, 283 insertions(+), 10 deletions(-) diff --git a/src/apps/chifra/internal/blocks/types_blockcount.go b/src/apps/chifra/internal/blocks/types_blockcount.go index f35afb638f..6a4c72aa49 100644 --- a/src/apps/chifra/internal/blocks/types_blockcount.go +++ b/src/apps/chifra/internal/blocks/types_blockcount.go @@ -10,6 +10,8 @@ package blocksPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" @@ -31,6 +33,11 @@ type simpleBlockCount struct { // EXISTING_CODE } +func (s *simpleBlockCount) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleBlockCount) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/chunks/types_chunkaddress.go b/src/apps/chifra/internal/chunks/types_chunkaddress.go index 88720fb458..ebbdc14f7f 100644 --- a/src/apps/chifra/internal/chunks/types_chunkaddress.go +++ b/src/apps/chifra/internal/chunks/types_chunkaddress.go @@ -10,6 +10,8 @@ package chunksPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) @@ -26,6 +28,11 @@ type simpleChunkAddress struct { // EXISTING_CODE } +func (s *simpleChunkAddress) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleChunkAddress) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/chunks/types_chunkbloom.go b/src/apps/chifra/internal/chunks/types_chunkbloom.go index 6112f15fca..f26550898b 100644 --- a/src/apps/chifra/internal/chunks/types_chunkbloom.go +++ b/src/apps/chifra/internal/chunks/types_chunkbloom.go @@ -10,6 +10,8 @@ package chunksPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) @@ -29,6 +31,11 @@ type simpleChunkBloom struct { // EXISTING_CODE } +func (s *simpleChunkBloom) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleChunkBloom) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/chunks/types_chunkindex.go b/src/apps/chifra/internal/chunks/types_chunkindex.go index 15741e2d33..17aa68df8a 100644 --- a/src/apps/chifra/internal/chunks/types_chunkindex.go +++ b/src/apps/chifra/internal/chunks/types_chunkindex.go @@ -10,6 +10,8 @@ package chunksPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) @@ -28,6 +30,11 @@ type simpleChunkIndex struct { // EXISTING_CODE } +func (s *simpleChunkIndex) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleChunkIndex) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/chunks/types_chunkpinreport.go b/src/apps/chifra/internal/chunks/types_chunkpinreport.go index 6e0eaa4a45..5c6606fab5 100644 --- a/src/apps/chifra/internal/chunks/types_chunkpinreport.go +++ b/src/apps/chifra/internal/chunks/types_chunkpinreport.go @@ -10,6 +10,8 @@ package chunksPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) @@ -27,6 +29,11 @@ type simpleChunkPinReport struct { // EXISTING_CODE } +func (s *simpleChunkPinReport) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleChunkPinReport) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/chunks/types_ipfspin.go b/src/apps/chifra/internal/chunks/types_ipfspin.go index efd22d5a9a..b7f0c77eb4 100644 --- a/src/apps/chifra/internal/chunks/types_ipfspin.go +++ b/src/apps/chifra/internal/chunks/types_ipfspin.go @@ -10,6 +10,7 @@ package chunksPkg // EXISTING_CODE import ( + "encoding/json" "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" @@ -29,6 +30,11 @@ type simpleIpfsPin struct { // EXISTING_CODE } +func (s *simpleIpfsPin) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleIpfsPin) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/chunks/types_reportcheck.go b/src/apps/chifra/internal/chunks/types_reportcheck.go index 0a24deb4af..ba068cbb49 100644 --- a/src/apps/chifra/internal/chunks/types_reportcheck.go +++ b/src/apps/chifra/internal/chunks/types_reportcheck.go @@ -9,7 +9,11 @@ package chunksPkg // EXISTING_CODE -import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" +) // EXISTING_CODE @@ -27,6 +31,11 @@ type simpleReportCheck struct { // EXISTING_CODE } +func (s *simpleReportCheck) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleReportCheck) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/monitors/types_monitorclean.go b/src/apps/chifra/internal/monitors/types_monitorclean.go index 1d65318e59..c8473e4c00 100644 --- a/src/apps/chifra/internal/monitors/types_monitorclean.go +++ b/src/apps/chifra/internal/monitors/types_monitorclean.go @@ -10,6 +10,8 @@ package monitorsPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) @@ -26,6 +28,11 @@ type simpleMonitorClean struct { // EXISTING_CODE } +func (s *simpleMonitorClean) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleMonitorClean) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/status/types_cacheitem.go b/src/apps/chifra/internal/status/types_cacheitem.go index cff1dd0992..c65f9d1c78 100644 --- a/src/apps/chifra/internal/status/types_cacheitem.go +++ b/src/apps/chifra/internal/status/types_cacheitem.go @@ -10,6 +10,8 @@ package statusPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) @@ -28,6 +30,11 @@ type simpleCacheItem struct { // EXISTING_CODE } +func (s *simpleCacheItem) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleCacheItem) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/status/types_status.go b/src/apps/chifra/internal/status/types_status.go index 456272d52a..98b08d7227 100644 --- a/src/apps/chifra/internal/status/types_status.go +++ b/src/apps/chifra/internal/status/types_status.go @@ -10,6 +10,7 @@ package statusPkg // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "sort" @@ -58,6 +59,11 @@ type simpleStatus struct { // EXISTING_CODE } +func (s *simpleStatus) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleStatus) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/traces/types_tracecount.go b/src/apps/chifra/internal/traces/types_tracecount.go index 611cff9f35..de8998bdd5 100644 --- a/src/apps/chifra/internal/traces/types_tracecount.go +++ b/src/apps/chifra/internal/traces/types_tracecount.go @@ -10,6 +10,8 @@ package tracesPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" @@ -28,6 +30,11 @@ type simpleTraceCount struct { // EXISTING_CODE } +func (s *simpleTraceCount) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleTraceCount) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/when/types_timestamp.go b/src/apps/chifra/internal/when/types_timestamp.go index 51a995081f..9a5682e31f 100644 --- a/src/apps/chifra/internal/when/types_timestamp.go +++ b/src/apps/chifra/internal/when/types_timestamp.go @@ -10,6 +10,8 @@ package whenPkg // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" @@ -26,6 +28,11 @@ type simpleTimestamp struct { // EXISTING_CODE } +func (s *simpleTimestamp) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleTimestamp) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/internal/when/types_timestampcount.go b/src/apps/chifra/internal/when/types_timestampcount.go index b2f226ca4f..0b7b0781e2 100644 --- a/src/apps/chifra/internal/when/types_timestampcount.go +++ b/src/apps/chifra/internal/when/types_timestampcount.go @@ -9,7 +9,11 @@ package whenPkg // EXISTING_CODE -import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" +) // EXISTING_CODE @@ -20,6 +24,11 @@ type simpleTimestampCount struct { // EXISTING_CODE } +func (s *simpleTimestampCount) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simpleTimestampCount) Raw() *types.RawModeler { return nil } diff --git a/src/apps/chifra/pkg/types/types_abi.go b/src/apps/chifra/pkg/types/types_abi.go index 59f2ba66bb..e5257e45cc 100644 --- a/src/apps/chifra/pkg/types/types_abi.go +++ b/src/apps/chifra/pkg/types/types_abi.go @@ -10,6 +10,8 @@ package types // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" ) @@ -30,6 +32,11 @@ type SimpleAbi struct { // EXISTING_CODE } +func (s *SimpleAbi) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleAbi) Raw() *RawAbi { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_appearance.go b/src/apps/chifra/pkg/types/types_appearance.go index cc885e3b51..87953c15e0 100644 --- a/src/apps/chifra/pkg/types/types_appearance.go +++ b/src/apps/chifra/pkg/types/types_appearance.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "sort" @@ -51,6 +52,11 @@ type SimpleAppearance struct { // EXISTING_CODE } +func (s *SimpleAppearance) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleAppearance) Raw() *RawAppearance { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_appearancecount.go b/src/apps/chifra/pkg/types/types_appearancecount.go index f2620bd8f4..c9ce523e87 100644 --- a/src/apps/chifra/pkg/types/types_appearancecount.go +++ b/src/apps/chifra/pkg/types/types_appearancecount.go @@ -9,7 +9,11 @@ package types // EXISTING_CODE -import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" +) // EXISTING_CODE @@ -30,6 +34,11 @@ type SimpleAppearanceCount struct { // EXISTING_CODE } +func (s *SimpleAppearanceCount) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleAppearanceCount) Raw() *RawAppearanceCount { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_block.go b/src/apps/chifra/pkg/types/types_block.go index 28422fb968..3a9d8ffbbe 100644 --- a/src/apps/chifra/pkg/types/types_block.go +++ b/src/apps/chifra/pkg/types/types_block.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -68,6 +69,11 @@ type SimpleBlock[Tx string | SimpleTransaction] struct { // EXISTING_CODE } +func (s *SimpleBlock[Tx]) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleBlock[Tx]) Raw() *RawBlock { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_bounds.go b/src/apps/chifra/pkg/types/types_bounds.go index 479d05c6c3..cffa69319c 100644 --- a/src/apps/chifra/pkg/types/types_bounds.go +++ b/src/apps/chifra/pkg/types/types_bounds.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" @@ -39,6 +40,11 @@ type SimpleBounds struct { // EXISTING_CODE } +func (s *SimpleBounds) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleBounds) Raw() *RawBounds { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_chain.go b/src/apps/chifra/pkg/types/types_chain.go index 6bb124dddb..15b9e9dadb 100644 --- a/src/apps/chifra/pkg/types/types_chain.go +++ b/src/apps/chifra/pkg/types/types_chain.go @@ -9,6 +9,7 @@ package types // EXISTING_CODE +import "encoding/json" // EXISTING_CODE @@ -37,6 +38,11 @@ type SimpleChain struct { // EXISTING_CODE } +func (s *SimpleChain) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleChain) Raw() *RawChain { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_chunkrecord.go b/src/apps/chifra/pkg/types/types_chunkrecord.go index dc4b06f4a7..51a49dc108 100644 --- a/src/apps/chifra/pkg/types/types_chunkrecord.go +++ b/src/apps/chifra/pkg/types/types_chunkrecord.go @@ -38,6 +38,11 @@ type SimpleChunkRecord struct { // EXISTING_CODE } +func (s *SimpleChunkRecord) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleChunkRecord) Raw() *RawChunkRecord { return s.raw } @@ -80,9 +85,4 @@ func (s *SimpleChunkRecord) FinishUnmarshal() { } // EXISTING_CODE -func (s *SimpleChunkRecord) String() string { - bytes, _ := json.MarshalIndent(s, "", " ") - return string(bytes) -} - // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkstats.go b/src/apps/chifra/pkg/types/types_chunkstats.go index 0243ecb015..e5c2b3d5cc 100644 --- a/src/apps/chifra/pkg/types/types_chunkstats.go +++ b/src/apps/chifra/pkg/types/types_chunkstats.go @@ -9,6 +9,8 @@ package types // EXISTING_CODE +import "encoding/json" + // EXISTING_CODE type RawChunkStats struct { @@ -48,6 +50,11 @@ type SimpleChunkStats struct { // EXISTING_CODE } +func (s *SimpleChunkStats) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleChunkStats) Raw() *RawChunkStats { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_function.go b/src/apps/chifra/pkg/types/types_function.go index 9c469726b8..fd3a304b09 100644 --- a/src/apps/chifra/pkg/types/types_function.go +++ b/src/apps/chifra/pkg/types/types_function.go @@ -59,6 +59,11 @@ type SimpleFunction struct { // EXISTING_CODE } +func (s *SimpleFunction) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleFunction) Raw() *RawFunction { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_log.go b/src/apps/chifra/pkg/types/types_log.go index 3d7f393680..cecb3cf432 100644 --- a/src/apps/chifra/pkg/types/types_log.go +++ b/src/apps/chifra/pkg/types/types_log.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -53,6 +54,11 @@ type SimpleLog struct { // EXISTING_CODE } +func (s *SimpleLog) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleLog) Raw() *RawLog { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_logfilter.go b/src/apps/chifra/pkg/types/types_logfilter.go index 113769944d..477a315a25 100644 --- a/src/apps/chifra/pkg/types/types_logfilter.go +++ b/src/apps/chifra/pkg/types/types_logfilter.go @@ -10,6 +10,8 @@ package types // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" ) @@ -36,6 +38,11 @@ type SimpleLogFilter struct { // EXISTING_CODE } +func (s *SimpleLogFilter) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleLogFilter) Raw() *RawLogFilter { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_manifest.go b/src/apps/chifra/pkg/types/types_manifest.go index 5d719e050e..a866568d93 100644 --- a/src/apps/chifra/pkg/types/types_manifest.go +++ b/src/apps/chifra/pkg/types/types_manifest.go @@ -10,6 +10,8 @@ package types // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" ) @@ -34,6 +36,11 @@ type SimpleManifest struct { // EXISTING_CODE } +func (s *SimpleManifest) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleManifest) Raw() *RawManifest { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_monitor.go b/src/apps/chifra/pkg/types/types_monitor.go index 61f210c073..62ac824ed7 100644 --- a/src/apps/chifra/pkg/types/types_monitor.go +++ b/src/apps/chifra/pkg/types/types_monitor.go @@ -10,6 +10,8 @@ package types // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" ) @@ -31,6 +33,11 @@ type SimpleMonitor struct { // EXISTING_CODE } +func (s *SimpleMonitor) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleMonitor) Raw() *RawMonitor { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_name.go b/src/apps/chifra/pkg/types/types_name.go index c29f910386..7973118081 100644 --- a/src/apps/chifra/pkg/types/types_name.go +++ b/src/apps/chifra/pkg/types/types_name.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" @@ -57,6 +58,11 @@ type SimpleName struct { // EXISTING_CODE } +func (s *SimpleName) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleName) Raw() *RawName { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_namedblock.go b/src/apps/chifra/pkg/types/types_namedblock.go index bddc27877a..26fc2a403c 100644 --- a/src/apps/chifra/pkg/types/types_namedblock.go +++ b/src/apps/chifra/pkg/types/types_namedblock.go @@ -10,6 +10,8 @@ package types // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) @@ -37,6 +39,11 @@ type SimpleNamedBlock struct { // EXISTING_CODE } +func (s *SimpleNamedBlock) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleNamedBlock) Raw() *RawNamedBlock { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_parameter.go b/src/apps/chifra/pkg/types/types_parameter.go index 7ef3f116b3..55e143f3e3 100644 --- a/src/apps/chifra/pkg/types/types_parameter.go +++ b/src/apps/chifra/pkg/types/types_parameter.go @@ -44,6 +44,11 @@ type SimpleParameter struct { // EXISTING_CODE } +func (s *SimpleParameter) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleParameter) Raw() *RawParameter { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_receipt.go b/src/apps/chifra/pkg/types/types_receipt.go index 500932ef2e..8cd2cc234c 100644 --- a/src/apps/chifra/pkg/types/types_receipt.go +++ b/src/apps/chifra/pkg/types/types_receipt.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -60,6 +61,11 @@ type SimpleReceipt struct { // EXISTING_CODE } +func (s *SimpleReceipt) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleReceipt) Raw() *RawReceipt { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_result.go b/src/apps/chifra/pkg/types/types_result.go index b54bb99b2f..13eb775a38 100644 --- a/src/apps/chifra/pkg/types/types_result.go +++ b/src/apps/chifra/pkg/types/types_result.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -50,6 +51,11 @@ type SimpleResult struct { // EXISTING_CODE } +func (s *SimpleResult) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleResult) Raw() *RawResult { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_slurp.go b/src/apps/chifra/pkg/types/types_slurp.go index a87b5d7c92..d0fc86b725 100644 --- a/src/apps/chifra/pkg/types/types_slurp.go +++ b/src/apps/chifra/pkg/types/types_slurp.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -83,6 +84,11 @@ type SimpleSlurp struct { // EXISTING_CODE } +func (s *SimpleSlurp) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleSlurp) Raw() *RawSlurp { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_state.go b/src/apps/chifra/pkg/types/types_state.go index 6931a9a72a..e60396fdae 100644 --- a/src/apps/chifra/pkg/types/types_state.go +++ b/src/apps/chifra/pkg/types/types_state.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -51,6 +52,11 @@ type SimpleState struct { // EXISTING_CODE } +func (s *SimpleState) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleState) Raw() *RawState { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_statement.go b/src/apps/chifra/pkg/types/types_statement.go index d9e810c6ad..34f5ffffca 100644 --- a/src/apps/chifra/pkg/types/types_statement.go +++ b/src/apps/chifra/pkg/types/types_statement.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -98,6 +99,11 @@ type SimpleStatement struct { // EXISTING_CODE } +func (s *SimpleStatement) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleStatement) Raw() *RawStatement { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_token.go b/src/apps/chifra/pkg/types/types_token.go index ebe6692e32..efa3c40506 100644 --- a/src/apps/chifra/pkg/types/types_token.go +++ b/src/apps/chifra/pkg/types/types_token.go @@ -10,6 +10,8 @@ package types // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) @@ -53,6 +55,11 @@ type SimpleToken struct { // EXISTING_CODE } +func (s *SimpleToken) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleToken) Raw() *RawToken { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_trace.go b/src/apps/chifra/pkg/types/types_trace.go index 39c6f9fd22..932ca909a2 100644 --- a/src/apps/chifra/pkg/types/types_trace.go +++ b/src/apps/chifra/pkg/types/types_trace.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -60,6 +61,11 @@ type SimpleTrace struct { // EXISTING_CODE } +func (s *SimpleTrace) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleTrace) Raw() *RawTrace { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_traceaction.go b/src/apps/chifra/pkg/types/types_traceaction.go index e2e68c2bd7..d029ea27c0 100644 --- a/src/apps/chifra/pkg/types/types_traceaction.go +++ b/src/apps/chifra/pkg/types/types_traceaction.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "io" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" @@ -56,6 +57,11 @@ type SimpleTraceAction struct { // EXISTING_CODE } +func (s *SimpleTraceAction) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleTraceAction) Raw() *RawTraceAction { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_tracefilter.go b/src/apps/chifra/pkg/types/types_tracefilter.go index 482119595d..745bb69e99 100644 --- a/src/apps/chifra/pkg/types/types_tracefilter.go +++ b/src/apps/chifra/pkg/types/types_tracefilter.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "strings" @@ -42,6 +43,11 @@ type SimpleTraceFilter struct { // EXISTING_CODE } +func (s *SimpleTraceFilter) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleTraceFilter) Raw() *RawTraceFilter { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_traceresult.go b/src/apps/chifra/pkg/types/types_traceresult.go index ab33c1821a..67c5b78d51 100644 --- a/src/apps/chifra/pkg/types/types_traceresult.go +++ b/src/apps/chifra/pkg/types/types_traceresult.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "io" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" @@ -39,6 +40,11 @@ type SimpleTraceResult struct { // EXISTING_CODE } +func (s *SimpleTraceResult) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleTraceResult) Raw() *RawTraceResult { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_transaction.go b/src/apps/chifra/pkg/types/types_transaction.go index bd34eed01d..a48a54499b 100644 --- a/src/apps/chifra/pkg/types/types_transaction.go +++ b/src/apps/chifra/pkg/types/types_transaction.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -98,6 +99,11 @@ type SimpleTransaction struct { // EXISTING_CODE } +func (s *SimpleTransaction) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleTransaction) Raw() *RawTransaction { return s.raw } diff --git a/src/apps/chifra/pkg/types/types_withdrawal.go b/src/apps/chifra/pkg/types/types_withdrawal.go index 4b25c6ab28..cbe194cce3 100644 --- a/src/apps/chifra/pkg/types/types_withdrawal.go +++ b/src/apps/chifra/pkg/types/types_withdrawal.go @@ -10,6 +10,7 @@ package types // EXISTING_CODE import ( + "encoding/json" "fmt" "io" "path/filepath" @@ -45,6 +46,11 @@ type SimpleWithdrawal struct { // EXISTING_CODE } +func (s *SimpleWithdrawal) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleWithdrawal) Raw() *RawWithdrawal { return s.raw } diff --git a/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl b/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl index 8d4dd09ca8..24898f24e0 100644 --- a/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl +++ b/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl @@ -18,6 +18,11 @@ type simple{{.Class}} struct { // EXISTING_CODE } +func (s *simple{{.Class}}) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *simple{{.Class}}) Raw() *types.RawModeler { return nil } diff --git a/src/dev_tools/goMaker/templates/src_apps_chifra_pkg_types_type.go.tmpl b/src/dev_tools/goMaker/templates/src_apps_chifra_pkg_types_type.go.tmpl index 0c3d6ba72d..dac189ca9d 100644 --- a/src/dev_tools/goMaker/templates/src_apps_chifra_pkg_types_type.go.tmpl +++ b/src/dev_tools/goMaker/templates/src_apps_chifra_pkg_types_type.go.tmpl @@ -24,6 +24,11 @@ type Simple{{.ModelName2}} struct { // EXISTING_CODE } +func (s *Simple{{.ModelName}}) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *Simple{{.ModelName}}) Raw() *Raw{{.Class}} { return s.raw } diff --git a/test/gold/tools/ethslurp/ethslurp_help.txt b/test/gold/tools/ethslurp/ethslurp_help.txt index 06cb4b43a5..dd39dbf731 100644 --- a/test/gold/tools/ethslurp/ethslurp_help.txt +++ b/test/gold/tools/ethslurp/ethslurp_help.txt @@ -1,6 +1,6 @@ chifra slurp -h Purpose: - Fetch data from Etherscan for any address. + Fetch data from Etherscan and other APIs for any address. Usage: chifra slurp [flags]
[address...] [block...] diff --git a/test/gold/tools/ethslurp/ethslurp_help_long.txt b/test/gold/tools/ethslurp/ethslurp_help_long.txt index 6b6fa3314b..dd01c7be7d 100644 --- a/test/gold/tools/ethslurp/ethslurp_help_long.txt +++ b/test/gold/tools/ethslurp/ethslurp_help_long.txt @@ -1,6 +1,6 @@ chifra slurp --help Purpose: - Fetch data from Etherscan for any address. + Fetch data from Etherscan and other APIs for any address. Usage: chifra slurp [flags]
[address...] [block...] From e75421cc202c407c1f969665b66630217d1a2614 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 08:44:23 -0400 Subject: [PATCH 02/18] Moves a few types out of internal --- .../chifra/internal/blocks/handle_count.go | 2 +- .../chifra/internal/monitors/handle_clean.go | 2 +- .../chifra/internal/traces/handle_counts.go | 2 +- .../chifra/internal/when/handle_ts_count.go | 2 +- .../chifra/internal/when/handle_ts_show.go | 2 +- .../blocks => pkg/types}/types_blockcount.go | 23 ++++++++++++------- .../types}/types_monitorclean.go | 21 +++++++++++------ .../when => pkg/types}/types_timestamp.go | 23 ++++++++++++------- .../types}/types_timestampcount.go | 22 +++++++++++------- .../traces => pkg/types}/types_tracecount.go | 23 ++++++++++++------- .../classDefinitions/blockcount.toml | 2 +- .../classDefinitions/monitorclean.toml | 2 +- .../templates/classDefinitions/timestamp.toml | 2 +- .../classDefinitions/timestampcount.toml | 2 +- .../classDefinitions/tracecount.toml | 2 +- 15 files changed, 83 insertions(+), 49 deletions(-) rename src/apps/chifra/{internal/blocks => pkg/types}/types_blockcount.go (87%) rename src/apps/chifra/{internal/monitors => pkg/types}/types_monitorclean.go (73%) rename src/apps/chifra/{internal/when => pkg/types}/types_timestamp.go (73%) rename src/apps/chifra/{internal/when => pkg/types}/types_timestampcount.go (66%) rename src/apps/chifra/{internal/traces => pkg/types}/types_tracecount.go (77%) diff --git a/src/apps/chifra/internal/blocks/handle_count.go b/src/apps/chifra/internal/blocks/handle_count.go index 95fbeccec0..2d28b093cf 100644 --- a/src/apps/chifra/internal/blocks/handle_count.go +++ b/src/apps/chifra/internal/blocks/handle_count.go @@ -41,7 +41,7 @@ func (opts *BlocksOptions) HandleCounts() error { return } - blockCount := simpleBlockCount{ + blockCount := types.SimpleBlockCount{ BlockNumber: block.BlockNumber, Timestamp: block.Timestamp, TransactionsCnt: uint64(len(block.Transactions)), diff --git a/src/apps/chifra/internal/monitors/handle_clean.go b/src/apps/chifra/internal/monitors/handle_clean.go index efe8d4cb55..5fb1269d97 100644 --- a/src/apps/chifra/internal/monitors/handle_clean.go +++ b/src/apps/chifra/internal/monitors/handle_clean.go @@ -22,7 +22,7 @@ func (opts *MonitorsOptions) HandleClean() error { fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { for _, mon := range monArray { addr := mon.Address.Hex() - s := simpleMonitorClean{ + s := types.SimpleMonitorClean{ Address: mon.Address, } if testMode { diff --git a/src/apps/chifra/internal/traces/handle_counts.go b/src/apps/chifra/internal/traces/handle_counts.go index 832ef3ee21..cd1026b80d 100644 --- a/src/apps/chifra/internal/traces/handle_counts.go +++ b/src/apps/chifra/internal/traces/handle_counts.go @@ -87,7 +87,7 @@ func (opts *TracesOptions) HandleCounts() error { }) for _, item := range items { - counter := simpleTraceCount{ + counter := types.SimpleTraceCount{ BlockNumber: uint64(item.BlockNumber), TransactionIndex: uint64(item.TransactionIndex), TransactionHash: item.Hash, diff --git a/src/apps/chifra/internal/when/handle_ts_count.go b/src/apps/chifra/internal/when/handle_ts_count.go index 349697825a..7c214db4b1 100644 --- a/src/apps/chifra/internal/when/handle_ts_count.go +++ b/src/apps/chifra/internal/when/handle_ts_count.go @@ -27,7 +27,7 @@ func (opts *WhenOptions) HandleTimestampCount() error { count = 5000000 } - s := simpleTimestampCount{ + s := types.SimpleTimestampCount{ Count: count, } diff --git a/src/apps/chifra/internal/when/handle_ts_show.go b/src/apps/chifra/internal/when/handle_ts_show.go index cf6a993261..58f332eb8b 100644 --- a/src/apps/chifra/internal/when/handle_ts_show.go +++ b/src/apps/chifra/internal/when/handle_ts_show.go @@ -38,7 +38,7 @@ func (opts *WhenOptions) HandleTimestampsShow() error { if err != nil { errorChan <- err } - s := simpleTimestamp{ + s := types.SimpleTimestamp{ BlockNumber: uint64(ts.Bn), Timestamp: base.Timestamp(ts.Ts), Diff: base.Timestamp(ts.Ts) - prev, diff --git a/src/apps/chifra/internal/blocks/types_blockcount.go b/src/apps/chifra/pkg/types/types_blockcount.go similarity index 87% rename from src/apps/chifra/internal/blocks/types_blockcount.go rename to src/apps/chifra/pkg/types/types_blockcount.go index 6a4c72aa49..fa85e3b4b3 100644 --- a/src/apps/chifra/internal/blocks/types_blockcount.go +++ b/src/apps/chifra/pkg/types/types_blockcount.go @@ -6,20 +6,24 @@ * the code inside of 'EXISTING_CODE' tags. */ -package blocksPkg +package types // EXISTING_CODE import ( "encoding/json" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) // EXISTING_CODE -type simpleBlockCount struct { +type RawBlockCount struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleBlockCount struct { AddressCnt uint64 `json:"addressCnt,omitempty"` BlockNumber base.Blknum `json:"blockNumber"` LogsCnt uint64 `json:"logsCnt,omitempty"` @@ -33,16 +37,16 @@ type simpleBlockCount struct { // EXISTING_CODE } -func (s *simpleBlockCount) String() string { +func (s *SimpleBlockCount) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleBlockCount) Raw() *types.RawModeler { +func (s *SimpleBlockCount) Raw() *RawModeler { return nil } -func (s *simpleBlockCount) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleBlockCount) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} @@ -111,15 +115,18 @@ func (s *simpleBlockCount) Model(chain, format string, verbose bool, extraOption } // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } } -func (s *simpleBlockCount) Date() string { +func (s *SimpleBlockCount) Date() string { return utils.FormattedDate(s.Timestamp) } // EXISTING_CODE // EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/apps/chifra/internal/monitors/types_monitorclean.go b/src/apps/chifra/pkg/types/types_monitorclean.go similarity index 73% rename from src/apps/chifra/internal/monitors/types_monitorclean.go rename to src/apps/chifra/pkg/types/types_monitorclean.go index c8473e4c00..ce50e26c4d 100644 --- a/src/apps/chifra/internal/monitors/types_monitorclean.go +++ b/src/apps/chifra/pkg/types/types_monitorclean.go @@ -6,19 +6,23 @@ * the code inside of 'EXISTING_CODE' tags. */ -package monitorsPkg +package types // EXISTING_CODE import ( "encoding/json" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // EXISTING_CODE -type simpleMonitorClean struct { +type RawMonitorClean struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleMonitorClean struct { Address base.Address `json:"address"` Dups int64 `json:"dups"` SizeNow int64 `json:"sizeNow"` @@ -28,16 +32,16 @@ type simpleMonitorClean struct { // EXISTING_CODE } -func (s *simpleMonitorClean) String() string { +func (s *SimpleMonitorClean) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleMonitorClean) Raw() *types.RawModeler { +func (s *SimpleMonitorClean) Raw() *RawModeler { return nil } -func (s *simpleMonitorClean) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleMonitorClean) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} @@ -56,7 +60,7 @@ func (s *simpleMonitorClean) Model(chain, format string, verbose bool, extraOpti } // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } @@ -64,3 +68,6 @@ func (s *simpleMonitorClean) Model(chain, format string, verbose bool, extraOpti // EXISTING_CODE // EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/apps/chifra/internal/when/types_timestamp.go b/src/apps/chifra/pkg/types/types_timestamp.go similarity index 73% rename from src/apps/chifra/internal/when/types_timestamp.go rename to src/apps/chifra/pkg/types/types_timestamp.go index 9a5682e31f..115ce4ef70 100644 --- a/src/apps/chifra/internal/when/types_timestamp.go +++ b/src/apps/chifra/pkg/types/types_timestamp.go @@ -6,20 +6,24 @@ * the code inside of 'EXISTING_CODE' tags. */ -package whenPkg +package types // EXISTING_CODE import ( "encoding/json" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) // EXISTING_CODE -type simpleTimestamp struct { +type RawTimestamp struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleTimestamp struct { BlockNumber base.Blknum `json:"blockNumber"` Diff int64 `json:"diff"` Timestamp base.Timestamp `json:"timestamp"` @@ -28,16 +32,16 @@ type simpleTimestamp struct { // EXISTING_CODE } -func (s *simpleTimestamp) String() string { +func (s *SimpleTimestamp) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleTimestamp) Raw() *types.RawModeler { +func (s *SimpleTimestamp) Raw() *RawModeler { return nil } -func (s *simpleTimestamp) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleTimestamp) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} @@ -54,15 +58,18 @@ func (s *simpleTimestamp) Model(chain, format string, verbose bool, extraOptions } // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } } -func (s *simpleTimestamp) Date() string { +func (s *SimpleTimestamp) Date() string { return utils.FormattedDate(s.Timestamp) } // EXISTING_CODE // EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/apps/chifra/internal/when/types_timestampcount.go b/src/apps/chifra/pkg/types/types_timestampcount.go similarity index 66% rename from src/apps/chifra/internal/when/types_timestampcount.go rename to src/apps/chifra/pkg/types/types_timestampcount.go index 0b7b0781e2..9dabbe9dc0 100644 --- a/src/apps/chifra/internal/when/types_timestampcount.go +++ b/src/apps/chifra/pkg/types/types_timestampcount.go @@ -6,34 +6,37 @@ * the code inside of 'EXISTING_CODE' tags. */ -package whenPkg +package types // EXISTING_CODE import ( "encoding/json" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // EXISTING_CODE -type simpleTimestampCount struct { +type RawTimestampCount struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleTimestampCount struct { Count uint64 `json:"count"` // EXISTING_CODE // EXISTING_CODE } -func (s *simpleTimestampCount) String() string { +func (s *SimpleTimestampCount) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleTimestampCount) Raw() *types.RawModeler { +func (s *SimpleTimestampCount) Raw() *RawModeler { return nil } -func (s *simpleTimestampCount) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleTimestampCount) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} @@ -46,7 +49,7 @@ func (s *simpleTimestampCount) Model(chain, format string, verbose bool, extraOp } // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } @@ -54,3 +57,6 @@ func (s *simpleTimestampCount) Model(chain, format string, verbose bool, extraOp // EXISTING_CODE // EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/apps/chifra/internal/traces/types_tracecount.go b/src/apps/chifra/pkg/types/types_tracecount.go similarity index 77% rename from src/apps/chifra/internal/traces/types_tracecount.go rename to src/apps/chifra/pkg/types/types_tracecount.go index de8998bdd5..122b55b117 100644 --- a/src/apps/chifra/internal/traces/types_tracecount.go +++ b/src/apps/chifra/pkg/types/types_tracecount.go @@ -6,20 +6,24 @@ * the code inside of 'EXISTING_CODE' tags. */ -package tracesPkg +package types // EXISTING_CODE import ( "encoding/json" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) // EXISTING_CODE -type simpleTraceCount struct { +type RawTraceCount struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleTraceCount struct { BlockNumber base.Blknum `json:"blockNumber"` Timestamp base.Timestamp `json:"timestamp"` TracesCnt uint64 `json:"tracesCnt"` @@ -30,16 +34,16 @@ type simpleTraceCount struct { // EXISTING_CODE } -func (s *simpleTraceCount) String() string { +func (s *SimpleTraceCount) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleTraceCount) Raw() *types.RawModeler { +func (s *SimpleTraceCount) Raw() *RawModeler { return nil } -func (s *simpleTraceCount) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleTraceCount) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} @@ -60,15 +64,18 @@ func (s *simpleTraceCount) Model(chain, format string, verbose bool, extraOption } // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } } -func (s *simpleTraceCount) Date() string { +func (s *SimpleTraceCount) Date() string { return utils.FormattedDate(s.Timestamp) } // EXISTING_CODE // EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml b/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml index 8367a13667..110e5a18be 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml @@ -4,4 +4,4 @@ doc_descr = "counts of various parts of the block data such as tx_count, trace_count, etc." doc_route = "236-blockCount" produced_by = "blocks" - go_output = "src/apps/chifra/internal/blocks" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml b/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml index 42c44d20ef..c027cc9edf 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml @@ -4,4 +4,4 @@ doc_descr = "report on cleaning dups out of monitors" doc_route = "427-monitorClean" produced_by = "monitors" - go_output = "src/apps/chifra/internal/monitors" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml b/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml index 2bf87550b3..c61a77b9d8 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml @@ -4,4 +4,4 @@ doc_descr = "the timestamp, date and difference in timestamp of previous block produced by chifra when" doc_route = "242-timestamp" produced_by = "when" - go_output = "src/apps/chifra/internal/when" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml b/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml index b34481b706..754465b1ae 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml @@ -4,4 +4,4 @@ doc_descr = "the number of timestamps in the timestamps database" doc_route = "245-timestampCount" produced_by = "when" - go_output = "src/apps/chifra/internal/when" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml b/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml index 61c3cca44b..9ad359d8a0 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml @@ -4,4 +4,4 @@ doc_descr = "counts the number of traces in a transaction" doc_route = "230-traceCount" produced_by = "traces" - go_output = "src/apps/chifra/internal/traces" + go_output = "src/apps/chifra/pkg/types" From add95f845c746aacf14c1625044ac917817a2142 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 10:39:44 -0400 Subject: [PATCH 03/18] Moves MetaData to types --- sdk/go/abis.go | 4 +- sdk/go/blocks.go | 3 +- sdk/go/chunks.go | 4 +- sdk/go/config.go | 4 +- sdk/go/export.go | 4 +- sdk/go/init.go | 4 +- sdk/go/list.go | 3 +- sdk/go/logs.go | 3 +- sdk/go/meta.go | 6 +- sdk/go/monitors.go | 4 +- sdk/go/names.go | 3 +- sdk/go/receipts.go | 3 +- sdk/go/result.go | 11 +- sdk/go/slurp.go | 3 +- sdk/go/state.go | 3 +- sdk/go/status.go | 4 +- sdk/go/tokens.go | 4 +- sdk/go/traces.go | 3 +- sdk/go/transactions.go | 3 +- sdk/go/when.go | 3 +- .../chifra/internal/scrape/notify_test.go | 2 + .../chifra/internal/scrape/scrape_manager.go | 2 + .../chifra/internal/status/handle_caches.go | 4 +- .../chifra/internal/status/handle_diagnose.go | 2 +- .../chifra/internal/status/handle_show.go | 190 +++++++++- .../chifra/internal/status/types_status.go | 351 ------------------ src/apps/chifra/pkg/notify/notification.go | 2 + src/apps/chifra/pkg/notify/scraper.go | 2 + src/apps/chifra/pkg/output/helpers/helpers.go | 2 + src/apps/chifra/pkg/output/json_writer.go | 2 + .../chifra/pkg/output/json_writer_test.go | 2 + src/apps/chifra/pkg/rpc/get_meta.go | 39 +- .../status => pkg/types}/types_cacheitem.go | 22 +- src/apps/chifra/pkg/types/types_metadata.go | 44 +++ src/apps/chifra/pkg/types/types_status.go | 164 ++++++++ .../templates/classDefinitions/cacheitem.toml | 2 +- .../templates/classDefinitions/status.toml | 2 +- .../goMaker/templates/sdk_go_route.go.tmpl | 2 +- 38 files changed, 466 insertions(+), 449 deletions(-) delete mode 100644 src/apps/chifra/internal/status/types_status.go rename src/apps/chifra/{internal/status => pkg/types}/types_cacheitem.go (72%) create mode 100644 src/apps/chifra/pkg/types/types_metadata.go create mode 100644 src/apps/chifra/pkg/types/types_status.go diff --git a/sdk/go/abis.go b/sdk/go/abis.go index 5e0e7e19d2..ab21e48804 100644 --- a/sdk/go/abis.go +++ b/sdk/go/abis.go @@ -18,7 +18,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" abis "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -79,7 +79,7 @@ func GetAbisOptions(args []string) (*AbisOptions, error) { return &opts, nil } -func (opts *AbisOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *AbisOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Abis(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/blocks.go b/sdk/go/blocks.go index f720df87be..3cc7c4ab0a 100644 --- a/sdk/go/blocks.go +++ b/sdk/go/blocks.go @@ -19,7 +19,6 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" blocks "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -96,7 +95,7 @@ func GetBlocksOptions(args []string) (*BlocksOptions, error) { return &opts, nil } -func (opts *BlocksOptions) Query() ([]types.SimpleBlock[string], *rpc.MetaData, error) { +func (opts *BlocksOptions) Query() ([]types.SimpleBlock[string], *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Blocks(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/chunks.go b/sdk/go/chunks.go index e3447658ca..474cc6aed8 100644 --- a/sdk/go/chunks.go +++ b/sdk/go/chunks.go @@ -19,7 +19,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" chunks "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -98,7 +98,7 @@ func GetChunksOptions(args []string) (*ChunksOptions, error) { return &opts, nil } -func (opts *ChunksOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *ChunksOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Chunks(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/config.go b/sdk/go/config.go index 984ef63031..9d36a5eb19 100644 --- a/sdk/go/config.go +++ b/sdk/go/config.go @@ -18,7 +18,7 @@ import ( "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" config "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -79,7 +79,7 @@ func GetConfigOptions(args []string) (*ConfigOptions, error) { return &opts, nil } -func (opts *ConfigOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *ConfigOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Config(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/export.go b/sdk/go/export.go index 075c6ce93d..73c6d04226 100644 --- a/sdk/go/export.go +++ b/sdk/go/export.go @@ -19,7 +19,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" export "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -108,7 +108,7 @@ func GetExportOptions(args []string) (*ExportOptions, error) { return &opts, nil } -func (opts *ExportOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *ExportOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Export(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/init.go b/sdk/go/init.go index 5985c409de..bb24218f78 100644 --- a/sdk/go/init.go +++ b/sdk/go/init.go @@ -18,7 +18,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" initPkg "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -73,7 +73,7 @@ func GetInitOptions(args []string) (*InitOptions, error) { return &opts, nil } -func (opts *InitOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *InitOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Init(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/list.go b/sdk/go/list.go index ad762ae73b..20b4ace325 100644 --- a/sdk/go/list.go +++ b/sdk/go/list.go @@ -18,7 +18,6 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" list "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -81,7 +80,7 @@ func GetListOptions(args []string) (*ListOptions, error) { return &opts, nil } -func (opts *ListOptions) Query() ([]types.SimpleAppearance, *rpc.MetaData, error) { +func (opts *ListOptions) Query() ([]types.SimpleAppearance, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.List(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/logs.go b/sdk/go/logs.go index 05cc7aebdf..280b215b8d 100644 --- a/sdk/go/logs.go +++ b/sdk/go/logs.go @@ -17,7 +17,6 @@ import ( "log" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" logs "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -72,7 +71,7 @@ func GetLogsOptions(args []string) (*LogsOptions, error) { return &opts, nil } -func (opts *LogsOptions) Query() ([]types.SimpleLog, *rpc.MetaData, error) { +func (opts *LogsOptions) Query() ([]types.SimpleLog, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Logs(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/meta.go b/sdk/go/meta.go index 82c3b41420..31036a31a6 100644 --- a/sdk/go/meta.go +++ b/sdk/go/meta.go @@ -1,10 +1,8 @@ package sdk -import ( - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" -) +import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" -func GetMetaData() (*rpc.MetaData, error) { +func GetMetaData() (*types.MetaData, error) { unused := BlocksOptions{ BlockIds: []string{"1"}, Hashes: true, diff --git a/sdk/go/monitors.go b/sdk/go/monitors.go index b789b121ad..07b5e455f1 100644 --- a/sdk/go/monitors.go +++ b/sdk/go/monitors.go @@ -17,7 +17,7 @@ import ( "log" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" monitors "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -79,7 +79,7 @@ func GetMonitorsOptions(args []string) (*MonitorsOptions, error) { return &opts, nil } -func (opts *MonitorsOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *MonitorsOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Monitors(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/names.go b/sdk/go/names.go index 54da0373f6..6810b5f969 100644 --- a/sdk/go/names.go +++ b/sdk/go/names.go @@ -18,7 +18,6 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" names "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -86,7 +85,7 @@ func GetNamesOptions(args []string) (*NamesOptions, error) { return &opts, nil } -func (opts *NamesOptions) Query() ([]types.SimpleName, *rpc.MetaData, error) { +func (opts *NamesOptions) Query() ([]types.SimpleName, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Names(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/receipts.go b/sdk/go/receipts.go index 46250295b8..f9697ac218 100644 --- a/sdk/go/receipts.go +++ b/sdk/go/receipts.go @@ -17,7 +17,6 @@ import ( "log" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" receipts "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -70,7 +69,7 @@ func GetReceiptsOptions(args []string) (*ReceiptsOptions, error) { return &opts, nil } -func (opts *ReceiptsOptions) Query() ([]types.SimpleReceipt, *rpc.MetaData, error) { +func (opts *ReceiptsOptions) Query() ([]types.SimpleReceipt, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Receipts(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/result.go b/sdk/go/result.go index a0276feee1..bb142a4836 100644 --- a/sdk/go/result.go +++ b/sdk/go/result.go @@ -1,13 +1,8 @@ package sdk -import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" - -// type abisResult struct { -// Data []bool `json:"data"` -// Meta rpc.MetaData `json:"meta"` -// } +import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" type Result[T any] struct { - Data []T `json:"data"` - Meta rpc.MetaData `json:"meta"` + Data []T `json:"data"` + Meta types.MetaData `json:"meta"` } diff --git a/sdk/go/slurp.go b/sdk/go/slurp.go index 90d93e60cc..3fa726b7da 100644 --- a/sdk/go/slurp.go +++ b/sdk/go/slurp.go @@ -18,7 +18,6 @@ import ( "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" slurp "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -97,7 +96,7 @@ func GetSlurpOptions(args []string) (*SlurpOptions, error) { return &opts, nil } -func (opts *SlurpOptions) Query() ([]types.SimpleSlurp, *rpc.MetaData, error) { +func (opts *SlurpOptions) Query() ([]types.SimpleSlurp, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Slurp(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/state.go b/sdk/go/state.go index 519352a93b..50faf15505 100644 --- a/sdk/go/state.go +++ b/sdk/go/state.go @@ -19,7 +19,6 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" state "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -91,7 +90,7 @@ func GetStateOptions(args []string) (*StateOptions, error) { return &opts, nil } -func (opts *StateOptions) Query() ([]types.SimpleState, *rpc.MetaData, error) { +func (opts *StateOptions) Query() ([]types.SimpleState, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.State(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/status.go b/sdk/go/status.go index 1733ce923a..37402fc6ee 100644 --- a/sdk/go/status.go +++ b/sdk/go/status.go @@ -18,7 +18,7 @@ import ( "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" status "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -82,7 +82,7 @@ func GetStatusOptions(args []string) (*StatusOptions, error) { return &opts, nil } -func (opts *StatusOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *StatusOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Status(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/tokens.go b/sdk/go/tokens.go index afecbe6c3e..1a609e88db 100644 --- a/sdk/go/tokens.go +++ b/sdk/go/tokens.go @@ -18,7 +18,7 @@ import ( "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" tokens "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE ) @@ -83,7 +83,7 @@ func GetTokensOptions(args []string) (*TokensOptions, error) { return &opts, nil } -func (opts *TokensOptions) Query() ([]bool, *rpc.MetaData, error) { +func (opts *TokensOptions) Query() ([]bool, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Tokens(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/traces.go b/sdk/go/traces.go index e5e5ec5562..569d9f3a08 100644 --- a/sdk/go/traces.go +++ b/sdk/go/traces.go @@ -17,7 +17,6 @@ import ( "log" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" traces "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -72,7 +71,7 @@ func GetTracesOptions(args []string) (*TracesOptions, error) { return &opts, nil } -func (opts *TracesOptions) Query() ([]types.SimpleTrace, *rpc.MetaData, error) { +func (opts *TracesOptions) Query() ([]types.SimpleTrace, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Traces(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/transactions.go b/sdk/go/transactions.go index 40f199fd3c..df65998ed6 100644 --- a/sdk/go/transactions.go +++ b/sdk/go/transactions.go @@ -18,7 +18,6 @@ import ( "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" transactions "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -88,7 +87,7 @@ func GetTransactionsOptions(args []string) (*TransactionsOptions, error) { return &opts, nil } -func (opts *TransactionsOptions) Query() ([]types.SimpleTransaction, *rpc.MetaData, error) { +func (opts *TransactionsOptions) Query() ([]types.SimpleTransaction, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.Transactions(&buffer); err != nil { logger.Fatal(err) diff --git a/sdk/go/when.go b/sdk/go/when.go index b71aee1d6d..2856b6acc8 100644 --- a/sdk/go/when.go +++ b/sdk/go/when.go @@ -18,7 +18,6 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" when "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" // EXISTING_CODE @@ -78,7 +77,7 @@ func GetWhenOptions(args []string) (*WhenOptions, error) { return &opts, nil } -func (opts *WhenOptions) Query() ([]types.SimpleNamedBlock, *rpc.MetaData, error) { +func (opts *WhenOptions) Query() ([]types.SimpleNamedBlock, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.When(&buffer); err != nil { logger.Fatal(err) diff --git a/src/apps/chifra/internal/scrape/notify_test.go b/src/apps/chifra/internal/scrape/notify_test.go index c6dd1f2785..4f10d9ec05 100644 --- a/src/apps/chifra/internal/scrape/notify_test.go +++ b/src/apps/chifra/internal/scrape/notify_test.go @@ -13,6 +13,8 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/uniq" ) +// TODO: Remove rpc.MetaData and use types.MetaData throughout + func TestNotify(t *testing.T) { results := make([]string, 0) var mutex sync.Mutex diff --git a/src/apps/chifra/internal/scrape/scrape_manager.go b/src/apps/chifra/internal/scrape/scrape_manager.go index 494ebbea76..3f3ed271f6 100644 --- a/src/apps/chifra/internal/scrape/scrape_manager.go +++ b/src/apps/chifra/internal/scrape/scrape_manager.go @@ -9,6 +9,8 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/tslib" ) +// TODO: Remove rpc.MetaData and use types.MetaData throughout + // BlazeManager manages the scraper by keeping track of the progress of the scrape and // maintaining the timestamp array and processed map. The processed map helps us know // if every block was visited or not. diff --git a/src/apps/chifra/internal/status/handle_caches.go b/src/apps/chifra/internal/status/handle_caches.go index aed3edeb1a..39977884c8 100644 --- a/src/apps/chifra/internal/status/handle_caches.go +++ b/src/apps/chifra/internal/status/handle_caches.go @@ -28,10 +28,10 @@ func (opts *StatusOptions) HandleCaches() error { filenameChan := make(chan walk.CacheFileInfo) var nRoutines int - counterMap := make(map[walk.CacheType]*simpleCacheItem) + counterMap := make(map[walk.CacheType]*types.SimpleCacheItem) nRoutines = len(opts.ModeTypes) for _, mT := range opts.ModeTypes { - counterMap[mT] = &simpleCacheItem{ + counterMap[mT] = &types.SimpleCacheItem{ CacheItemType: walk.CacheName(mT), Items: make([]any, 0), LastCached: now.Format("2006-01-02 15:04:05"), diff --git a/src/apps/chifra/internal/status/handle_diagnose.go b/src/apps/chifra/internal/status/handle_diagnose.go index f30a439a02..addda0b6e0 100644 --- a/src/apps/chifra/internal/status/handle_diagnose.go +++ b/src/apps/chifra/internal/status/handle_diagnose.go @@ -20,7 +20,7 @@ func (opts *StatusOptions) HandleDiagnose() error { } // We want to short circuit the output in the non-json case - if s.toTemplate(opts.Globals.Writer, testMode, opts.Diagnose, logger.LogTimerOn(), opts.Globals.Format) { + if toTemplate(s, opts.Globals.Writer, testMode, opts.Diagnose, logger.LogTimerOn(), opts.Globals.Format) { return } diff --git a/src/apps/chifra/internal/status/handle_show.go b/src/apps/chifra/internal/status/handle_show.go index ae98f8a1e2..504f7d3ee3 100644 --- a/src/apps/chifra/internal/status/handle_show.go +++ b/src/apps/chifra/internal/status/handle_show.go @@ -2,10 +2,20 @@ package statusPkg import ( "context" + "fmt" + "io" + "strings" + "text/template" + "time" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/colors" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/tslib" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/validate" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/version" ) func (opts *StatusOptions) HandleShow() error { @@ -20,7 +30,7 @@ func (opts *StatusOptions) HandleShow() error { } // We want to short circuit the output in the non-json case - if s.toTemplate(opts.Globals.Writer, testMode, opts.Diagnose, logger.LogTimerOn(), opts.Globals.Format) { + if toTemplate(s, opts.Globals.Writer, testMode, opts.Diagnose, logger.LogTimerOn(), opts.Globals.Format) { return } @@ -32,3 +42,181 @@ func (opts *StatusOptions) HandleShow() error { } return output.StreamMany(ctx, fetchData, opts.Globals.OutputOptsWithExtra(extra)) } + +func ToProgress(chain string, diagnose bool, meta *types.MetaData) string { + nTs, _ := tslib.NTimestamps(chain) // when the file has one record, the block is zero, etc. + if nTs > 0 { + nTs-- + } + format := "%d, %d, %d, %d ts: %d" + return fmt.Sprintf(format, meta.Latest, meta.Finalized, meta.Staging, meta.Unripe, nTs) +} + +func (opts *StatusOptions) GetSimpleStatus(diagnose bool) (*types.SimpleStatus, error) { + chain := opts.Globals.Chain + testMode := opts.Globals.TestMode + + meta, err := opts.Conn.GetMetaData(false) + if err != nil { + return nil, err + } + diffs := &types.MetaData{ + Latest: 0, + Finalized: meta.Latest - meta.Finalized, + Staging: meta.Latest - meta.Staging, + Unripe: meta.Latest - meta.Unripe, + Ripe: meta.Latest - meta.Ripe, + } + + vers, err := opts.Conn.GetClientVersion() + if err != nil { + return nil, err + } + + provider := config.GetChain(chain).RpcProvider + s := &types.SimpleStatus{ + ClientVersion: vers, + Version: version.LibraryVersion, + RpcProvider: provider, + RootConfig: config.PathToRootConfig(), + ChainConfig: config.MustGetPathToChainConfig(chain), + CachePath: config.PathToCache(chain), + IndexPath: config.PathToIndex(chain), + Progress: ToProgress(chain, diagnose, meta), + IsTesting: testMode, + IsApi: opts.Globals.IsApiMode(), + IsArchive: opts.Conn.IsNodeArchive(), + IsTracing: opts.Conn.IsNodeTracing(), + HasEsKey: validate.HasArticulationKey(true), + HasPinKey: len(config.GetKey("pinata").ApiKey) > 0 || len(config.GetKey("pinata").Secret) > 0, + Chain: chain, + NetworkId: fmt.Sprint(meta.NetworkId), + ChainId: fmt.Sprint(meta.ChainId), + Meta: meta, + Diffs: diffs, + // Finalized: meta.Latest - meta.Finalized, + // Staging: meta.Latest - meta.Staging, + // Unripe: meta.Latest - meta.Unripe, + // Ripe: meta.Latest - meta.Ripe, + } + + if testMode { + s.ClientVersion = "Client version" + s.Version = "GHC-TrueBlocks//vers-beta--git-hash---git-ts-" + s.RpcProvider = "--providers--" + s.RootConfig = "--paths--" + s.ChainConfig = "--paths--" + s.CachePath = "--paths--" + s.IndexPath = "--paths--" + s.Progress = "--client--, --final--, --staging--, --unripe-- ts: --ts--" + s.HasPinKey = false // the test machine doesn't have a key + } + + return s, nil +} + +func toTemplate(s *types.SimpleStatus, w io.Writer, testMode, diagnose, logTimerOn bool, format string) bool { + if format == "json" { + return false + } + + var timeDatePart string + if logTimerOn { + now := time.Now() + timeDatePart = now.Format("02-01|15:04:05.000 ") + } else { + timeDatePart = "INFO[DATE|TIME] " + } + + table := templateStr + table = strings.Replace(table, "[CLIENT]", getClientTemplate(), -1) + table = strings.Replace(table, "[VERSION]", getVersionTemplate(), -1) + table = strings.Replace(table, "[IDS]", getIdTemplate(), -1) + table = strings.Replace(table, "[PROGRESS]", getProgress(s, testMode, diagnose), -1) + table = strings.Replace(table, "INFO ", timeDatePart+colors.Green, -1) + table = strings.Replace(table, "[RED]", colors.Red, -1) + table = strings.Replace(table, "[GREEN]", colors.Green, -1) + table = strings.Replace(table, "[OFF]", colors.Off, -1) + table = strings.Replace(table, ":", ":"+colors.Off, -1) + + t, err := template.New("status").Parse(table) + if err != nil { + logger.Fatal("should not happen ==> bad template.", err) + return false + } + + _ = t.Execute(w, s) + return true +} + +func getClientTemplate() string { + archive := "{{if .IsArchive}}[GREEN]archive[OFF]{{else}}[RED]no archive[OFF]{{end}}" + testing := "{{if .IsTesting}}[GREEN]testing[OFF], {{end}}" + tracing := "{{if .IsTracing}}[GREEN]tracing[OFF]{{else}}[RED]no tracing[OFF]{{end}}" + return "{{.ClientVersion}} (" + archive + ", " + testing + tracing + ")" +} + +func getVersionTemplate() string { + esKey := "{{if .HasEsKey}}[GREEN]eskey[OFF]{{else}}[RED]no eskey[OFF]{{end}}" + pinKey := "{{if .HasPinKey}}[GREEN]pinkey[OFF]{{else}}[RED]no pinkey[OFF]{{end}}" + return "{{.Version}} (" + esKey + ", " + pinKey + ")" +} + +func getIdTemplate() string { + networkId := "{{if eq .NetworkId \"0\"}}[RED]{{.NetworkId}}[OFF]{{else}}[GREEN]{{.NetworkId}}[OFF]{{end}}" + chainId := "{{if eq .ChainId \"0\"}}[RED]{{.ChainId}}[OFF]{{else}}[GREEN]{{.ChainId}}[OFF]{{end}}" + return networkId + "/" + chainId +} + +func getProgress(s *types.SimpleStatus, testMode, diagnose bool) string { + if diagnose { + if testMode { + return "--diagnostics--" + } + nTs, _ := tslib.NTimestamps(s.Meta.Chain) // when the file has one record, the block is zero, etc. + if nTs > 0 { + nTs-- + } + nTsDiff := s.Meta.Latest - nTs + if nTs > s.Meta.Latest { + nTsDiff = 0 + } + ret := ` +INFO [OFF] Chain Head [GREEN]{{.Meta.Latest}}[OFF] +INFO [OFF] Finalized [GREEN]{{.Meta.Finalized}}[OFF] ([GREEN]{{.Diffs.Finalized}}[OFF] behind head) +INFO [OFF] Stage [GREEN]{{.Meta.Staging}}[OFF] ([GREEN]{{.Diffs.Staging}}[OFF] behind head) +INFO [OFF] Indexing [GREEN]{{.Meta.Unripe}}[OFF] ([GREEN]{{.Diffs.Unripe}}[OFF] behind head) +INFO [OFF] Timestamps [GREEN]{nTs}[OFF] ([GREEN]{nTsDiff}[OFF] behind head) +` + ret = strings.Replace(ret, "{nTs}", fmt.Sprint(nTs), -1) + ret = strings.Replace(ret, "{nTsDiff}", fmt.Sprint(nTsDiff), -1) + return ret + } + + return " {{.Progress}}" +} + +const templateStr = `INFO Client: [CLIENT] +INFO TrueBlocks: [VERSION] +INFO RPC Provider: {{.RpcProvider}} - {{.Chain}} ([IDS]) +INFO Root Config Path: {{.RootConfig}} +INFO Chain Config Path: {{.ChainConfig}} +INFO Cache Path: {{.CachePath}} +INFO Index Path: {{.IndexPath}} +INFO Progress:[PROGRESS] +` + +/* +TODO: Better diagnostics (see #3209) +TODO: When Node synced, successfull chifra init but scraper not running +TODO: +TODO: WARN: Index is behind the chain head, but scraper is not running. +TODO: WARN: This means chifra is not aware of latest transactions and can return incomplete data. +TODO: WARN: Run `chifra daemon --scrape index` to solve the issue. +TODO: +TODO: Node is not syncing +TODO: +TODO: WARN: Your node seems to be syncing. During this state it can refuse queries from chifra +TODO: WARN: or return incomplete data. If you observe such issues, please wait until your node +TODO: WARN: is fully synced and your index catches up to the chain head. +*/ diff --git a/src/apps/chifra/internal/status/types_status.go b/src/apps/chifra/internal/status/types_status.go deleted file mode 100644 index 98b08d7227..0000000000 --- a/src/apps/chifra/internal/status/types_status.go +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. -// Use of this source code is governed by a license that can -// be found in the LICENSE file. -/* - * Parts of this file were auto generated. Edit only those parts of - * the code inside of 'EXISTING_CODE' tags. - */ - -package statusPkg - -// EXISTING_CODE -import ( - "encoding/json" - "fmt" - "io" - "sort" - "strings" - "text/template" - "time" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/colors" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/tslib" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/validate" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/version" -) - -// EXISTING_CODE - -type simpleStatus struct { - CachePath string `json:"cachePath,omitempty"` - Caches []simpleCacheItem `json:"caches"` - Chain string `json:"chain,omitempty"` - ChainConfig string `json:"chainConfig,omitempty"` - ChainId string `json:"chainId,omitempty"` - Chains []types.SimpleChain `json:"chains"` - ClientVersion string `json:"clientVersion,omitempty"` - HasEsKey bool `json:"hasEsKey,omitempty"` - HasPinKey bool `json:"hasPinKey,omitempty"` - IndexPath string `json:"indexPath,omitempty"` - IsApi bool `json:"isApi,omitempty"` - IsArchive bool `json:"isArchive,omitempty"` - IsScraping bool `json:"isScraping,omitempty"` - IsTesting bool `json:"isTesting,omitempty"` - IsTracing bool `json:"isTracing,omitempty"` - NetworkId string `json:"networkId,omitempty"` - Progress string `json:"progress,omitempty"` - RootConfig string `json:"rootConfig,omitempty"` - RpcProvider string `json:"rpcProvider,omitempty"` - Version string `json:"version,omitempty"` - - // EXISTING_CODE - Meta *rpc.MetaData `json:"meta,omitempty"` - Diffs *rpc.MetaData `json:"diffs,omitempty"` - // EXISTING_CODE -} - -func (s *simpleStatus) String() string { - bytes, _ := json.Marshal(s) - return string(bytes) -} - -func (s *simpleStatus) Raw() *types.RawModeler { - return nil -} - -func (s *simpleStatus) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { - var model = map[string]interface{}{} - var order = []string{} - - // EXISTING_CODE - model = map[string]interface{}{ - "cachePath": s.CachePath, - "chainConfig": s.ChainConfig, - "clientVersion": s.ClientVersion, - "hasEsKey": s.HasEsKey, - "hasPinKey": s.HasPinKey, - "indexPath": s.IndexPath, - "isApi": s.IsApi, - "isArchive": s.IsArchive, - "isTesting": s.IsTesting, - "isTracing": s.IsTracing, - "rootConfig": s.RootConfig, - "rpcProvider": s.RpcProvider, - "trueblocksVersion": s.Version, - } - order = []string{ - "cachePath", - "chainConfig", - "clientVersion", - "hasEsKey", - "hasPinKey", - "indexPath", - "isApi", - "isArchive", - "isTesting", - "isTracing", - "rootConfig", - "rpcProvider", - "trueblocksVersion", - } - - if extraOptions != nil && extraOptions["showProgress"] == true { - model["progress"] = s.Progress - order = append(order, "progress") - } - - testMode := extraOptions["testMode"] == true - if len(s.Caches) > 0 { - if testMode { - for i := 0; i < len(s.Caches); i++ { - s.Caches[i].Path = "--paths--" - s.Caches[i].LastCached = "--lastCached--" - s.Caches[i].NFiles = 123 - s.Caches[i].NFolders = 456 - s.Caches[i].SizeInBytes = 789 - } - } - model["caches"] = s.Caches - order = append(order, "caches") - } - - if extraOptions["chains"] == true { - var chains []types.SimpleChain - if extraOptions["testMode"] == true { - ch := types.SimpleChain{ - Chain: "testChain", - ChainId: 12345, - LocalExplorer: "http://localhost:8080", - RpcProvider: "http://localhost:8545", - Symbol: "ETH", - } - chains = append(chains, ch) - } else { - chainArray := config.GetChains() - for _, chain := range chainArray { - ch := types.SimpleChain{ - Chain: chain.Chain, - ChainId: utils.MustParseUint(chain.ChainId), - LocalExplorer: chain.LocalExplorer, - RemoteExplorer: chain.RemoteExplorer, - RpcProvider: chain.RpcProvider, - IpfsGateway: chain.IpfsGateway, - Symbol: chain.Symbol, - } - chains = append(chains, ch) - } - sort.Slice(chains, func(i, j int) bool { - if chains[i].ChainId == chains[j].ChainId { - return chains[i].Chain < chains[j].Chain - } - return chains[i].ChainId < chains[j].ChainId - }) - } - model["chains"] = chains - order = append(order, "chains") - } - // EXISTING_CODE - - return types.Model{ - Data: model, - Order: order, - } -} - -// EXISTING_CODE -// - -func ToProgress(chain string, diagnose bool, meta *rpc.MetaData) string { - nTs, _ := tslib.NTimestamps(chain) // when the file has one record, the block is zero, etc. - if nTs > 0 { - nTs-- - } - format := "%d, %d, %d, %d ts: %d" - return fmt.Sprintf(format, meta.Latest, meta.Finalized, meta.Staging, meta.Unripe, nTs) -} - -func (opts *StatusOptions) GetSimpleStatus(diagnose bool) (*simpleStatus, error) { - chain := opts.Globals.Chain - testMode := opts.Globals.TestMode - - meta, err := opts.Conn.GetMetaData(false) - if err != nil { - return nil, err - } - diffs := &rpc.MetaData{ - Latest: 0, - Finalized: meta.Latest - meta.Finalized, - Staging: meta.Latest - meta.Staging, - Unripe: meta.Latest - meta.Unripe, - Ripe: meta.Latest - meta.Ripe, - } - - vers, err := opts.Conn.GetClientVersion() - if err != nil { - return nil, err - } - - provider := config.GetChain(chain).RpcProvider - s := &simpleStatus{ - ClientVersion: vers, - Version: version.LibraryVersion, - RpcProvider: provider, - RootConfig: config.PathToRootConfig(), - ChainConfig: config.MustGetPathToChainConfig(chain), - CachePath: config.PathToCache(chain), - IndexPath: config.PathToIndex(chain), - Progress: ToProgress(chain, diagnose, meta), - IsTesting: testMode, - IsApi: opts.Globals.IsApiMode(), - IsArchive: opts.Conn.IsNodeArchive(), - IsTracing: opts.Conn.IsNodeTracing(), - HasEsKey: validate.HasArticulationKey(true), - HasPinKey: len(config.GetKey("pinata").ApiKey) > 0 || len(config.GetKey("pinata").Secret) > 0, - Chain: chain, - NetworkId: fmt.Sprint(meta.NetworkId), - ChainId: fmt.Sprint(meta.ChainId), - Meta: meta, - Diffs: diffs, - // Finalized: meta.Latest - meta.Finalized, - // Staging: meta.Latest - meta.Staging, - // Unripe: meta.Latest - meta.Unripe, - // Ripe: meta.Latest - meta.Ripe, - } - - if testMode { - s.ClientVersion = "Client version" - s.Version = "GHC-TrueBlocks//vers-beta--git-hash---git-ts-" - s.RpcProvider = "--providers--" - s.RootConfig = "--paths--" - s.ChainConfig = "--paths--" - s.CachePath = "--paths--" - s.IndexPath = "--paths--" - s.Progress = "--client--, --final--, --staging--, --unripe-- ts: --ts--" - s.HasPinKey = false // the test machine doesn't have a key - } - - return s, nil -} - -func (s *simpleStatus) toTemplate(w io.Writer, testMode, diagnose, logTimerOn bool, format string) bool { - if format == "json" { - return false - } - - var timeDatePart string - if logTimerOn { - now := time.Now() - timeDatePart = now.Format("02-01|15:04:05.000 ") - } else { - timeDatePart = "INFO[DATE|TIME] " - } - - table := templateStr - table = strings.Replace(table, "[CLIENT]", getClientTemplate(), -1) - table = strings.Replace(table, "[VERSION]", getVersionTemplate(), -1) - table = strings.Replace(table, "[IDS]", getIdTemplate(), -1) - table = strings.Replace(table, "[PROGRESS]", s.getProgress(testMode, diagnose), -1) - table = strings.Replace(table, "INFO ", timeDatePart+colors.Green, -1) - table = strings.Replace(table, "[RED]", colors.Red, -1) - table = strings.Replace(table, "[GREEN]", colors.Green, -1) - table = strings.Replace(table, "[OFF]", colors.Off, -1) - table = strings.Replace(table, ":", ":"+colors.Off, -1) - - t, err := template.New("status").Parse(table) - if err != nil { - logger.Fatal("should not happen ==> bad template.", err) - return false - } - - _ = t.Execute(w, s) - return true -} - -func getClientTemplate() string { - archive := "{{if .IsArchive}}[GREEN]archive[OFF]{{else}}[RED]no archive[OFF]{{end}}" - testing := "{{if .IsTesting}}[GREEN]testing[OFF], {{end}}" - tracing := "{{if .IsTracing}}[GREEN]tracing[OFF]{{else}}[RED]no tracing[OFF]{{end}}" - return "{{.ClientVersion}} (" + archive + ", " + testing + tracing + ")" -} - -func getVersionTemplate() string { - esKey := "{{if .HasEsKey}}[GREEN]eskey[OFF]{{else}}[RED]no eskey[OFF]{{end}}" - pinKey := "{{if .HasPinKey}}[GREEN]pinkey[OFF]{{else}}[RED]no pinkey[OFF]{{end}}" - return "{{.Version}} (" + esKey + ", " + pinKey + ")" -} - -func getIdTemplate() string { - networkId := "{{if eq .NetworkId \"0\"}}[RED]{{.NetworkId}}[OFF]{{else}}[GREEN]{{.NetworkId}}[OFF]{{end}}" - chainId := "{{if eq .ChainId \"0\"}}[RED]{{.ChainId}}[OFF]{{else}}[GREEN]{{.ChainId}}[OFF]{{end}}" - return networkId + "/" + chainId -} - -func (s *simpleStatus) getProgress(testMode, diagnose bool) string { - if diagnose { - if testMode { - return "--diagnostics--" - } - nTs, _ := tslib.NTimestamps(s.Meta.Chain) // when the file has one record, the block is zero, etc. - if nTs > 0 { - nTs-- - } - nTsDiff := s.Meta.Latest - nTs - if nTs > s.Meta.Latest { - nTsDiff = 0 - } - ret := ` -INFO [OFF] Chain Head [GREEN]{{.Meta.Latest}}[OFF] -INFO [OFF] Finalized [GREEN]{{.Meta.Finalized}}[OFF] ([GREEN]{{.Diffs.Finalized}}[OFF] behind head) -INFO [OFF] Stage [GREEN]{{.Meta.Staging}}[OFF] ([GREEN]{{.Diffs.Staging}}[OFF] behind head) -INFO [OFF] Indexing [GREEN]{{.Meta.Unripe}}[OFF] ([GREEN]{{.Diffs.Unripe}}[OFF] behind head) -INFO [OFF] Timestamps [GREEN]{nTs}[OFF] ([GREEN]{nTsDiff}[OFF] behind head) -` - ret = strings.Replace(ret, "{nTs}", fmt.Sprint(nTs), -1) - ret = strings.Replace(ret, "{nTsDiff}", fmt.Sprint(nTsDiff), -1) - return ret - } - - return " {{.Progress}}" -} - -const templateStr = `INFO Client: [CLIENT] -INFO TrueBlocks: [VERSION] -INFO RPC Provider: {{.RpcProvider}} - {{.Chain}} ([IDS]) -INFO Root Config Path: {{.RootConfig}} -INFO Chain Config Path: {{.ChainConfig}} -INFO Cache Path: {{.CachePath}} -INFO Index Path: {{.IndexPath}} -INFO Progress:[PROGRESS] -` - -/* -TODO: Better diagnostics (see #3209) -TODO: When Node synced, successfull chifra init but scraper not running -TODO: -TODO: WARN: Index is behind the chain head, but scraper is not running. -TODO: WARN: This means chifra is not aware of latest transactions and can return incomplete data. -TODO: WARN: Run `chifra daemon --scrape index` to solve the issue. -TODO: -TODO: Node is not syncing -TODO: -TODO: WARN: Your node seems to be syncing. During this state it can refuse queries from chifra -TODO: WARN: or return incomplete data. If you observe such issues, please wait until your node -TODO: WARN: is fully synced and your index catches up to the chain head. -*/ - -// EXISTING_CODE diff --git a/src/apps/chifra/pkg/notify/notification.go b/src/apps/chifra/pkg/notify/notification.go index 6827bcc355..661ed93750 100644 --- a/src/apps/chifra/pkg/notify/notification.go +++ b/src/apps/chifra/pkg/notify/notification.go @@ -2,6 +2,8 @@ package notify import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" +// TODO: Remove rpc.MetaData and use types.MetaData throughout + type Message string type Notification[T NotificationPayload] struct { diff --git a/src/apps/chifra/pkg/notify/scraper.go b/src/apps/chifra/pkg/notify/scraper.go index 8e12f5ae08..e53cae566f 100644 --- a/src/apps/chifra/pkg/notify/scraper.go +++ b/src/apps/chifra/pkg/notify/scraper.go @@ -7,6 +7,8 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/uniq" ) +// TODO: Remove rpc.MetaData and use types.MetaData throughout + const ( MessageChunkWritten Message = "chunkWritten" MessageStageUpdated Message = "stageUpdated" diff --git a/src/apps/chifra/pkg/output/helpers/helpers.go b/src/apps/chifra/pkg/output/helpers/helpers.go index a09bafedf9..aec8beb53f 100644 --- a/src/apps/chifra/pkg/output/helpers/helpers.go +++ b/src/apps/chifra/pkg/output/helpers/helpers.go @@ -11,6 +11,8 @@ import ( "github.com/spf13/cobra" ) +// TODO: Remove rpc.MetaData and use types.MetaData throughout + var discardWriter = io.Writer(nil) func init() { diff --git a/src/apps/chifra/pkg/output/json_writer.go b/src/apps/chifra/pkg/output/json_writer.go index 8dcbf70397..4cf1b8d4dc 100644 --- a/src/apps/chifra/pkg/output/json_writer.go +++ b/src/apps/chifra/pkg/output/json_writer.go @@ -10,6 +10,8 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" ) +// TODO: Remove rpc.MetaData and use types.MetaData throughout + type FieldType int var comma = "," diff --git a/src/apps/chifra/pkg/output/json_writer_test.go b/src/apps/chifra/pkg/output/json_writer_test.go index f5b94fa0e3..70d883854f 100644 --- a/src/apps/chifra/pkg/output/json_writer_test.go +++ b/src/apps/chifra/pkg/output/json_writer_test.go @@ -10,6 +10,8 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" ) +// TODO: Remove rpc.MetaData and use types.MetaData throughout + func helperReportStringMismatch(t *testing.T, expected, result string) { for i, ch := range expected { if result[i] != byte(ch) { diff --git a/src/apps/chifra/pkg/rpc/get_meta.go b/src/apps/chifra/pkg/rpc/get_meta.go index 69df0123a3..bf20f5834d 100644 --- a/src/apps/chifra/pkg/rpc/get_meta.go +++ b/src/apps/chifra/pkg/rpc/get_meta.go @@ -6,23 +6,13 @@ package rpc import ( "context" - "encoding/json" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/walk" ) -type MetaData struct { - Latest uint64 `json:"client"` - Finalized uint64 `json:"finalized"` - Staging uint64 `json:"staging"` - Ripe uint64 `json:"ripe"` - Unripe uint64 `json:"unripe"` - ChainId uint64 `json:"chainId,omitempty"` - NetworkId uint64 `json:"networkId,omitempty"` - Chain string `json:"chain,omitempty"` -} +// TODO: use types.MetaData throughout func (conn *Connection) GetMetaData(testmode bool) (*MetaData, error) { chainId, networkId, err := conn.GetClientIDs() @@ -86,27 +76,6 @@ func (conn *Connection) GetMetaData(testmode bool) (*MetaData, error) { return &meta, nil } -func (m *MetaData) String() string { - ret, _ := json.MarshalIndent(m, "", " ") - return string(ret) -} +// TODO: Remove rpc.MetaData and use types.MetaData throughout -// Highest returns the height of the index (i.e., max between the finalized, staging, and ripe indexes). -func (m *MetaData) IndexHeight() base.Blknum { - return utils.Max(m.Finalized, utils.Max(m.Staging, m.Ripe)) -} - -// NextIndexHeight returns the block after the height of the index. -func (m *MetaData) NextIndexHeight() base.Blknum { - return m.IndexHeight() + 1 -} - -// ChainHeight returns the block after the height of the index. -func (m *MetaData) ChainHeight() base.Blknum { - return m.Latest -} - -// StageHieght returns the highest block that's been staged -func (m *MetaData) StageHeight() base.Blknum { - return m.Staging -} +type MetaData = types.MetaData diff --git a/src/apps/chifra/internal/status/types_cacheitem.go b/src/apps/chifra/pkg/types/types_cacheitem.go similarity index 72% rename from src/apps/chifra/internal/status/types_cacheitem.go rename to src/apps/chifra/pkg/types/types_cacheitem.go index c65f9d1c78..9a29095b12 100644 --- a/src/apps/chifra/internal/status/types_cacheitem.go +++ b/src/apps/chifra/pkg/types/types_cacheitem.go @@ -6,18 +6,21 @@ * the code inside of 'EXISTING_CODE' tags. */ -package statusPkg +package types // EXISTING_CODE import ( "encoding/json" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // EXISTING_CODE -type simpleCacheItem struct { +type RawCacheItem struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleCacheItem struct { Items []any `json:"items"` LastCached string `json:"lastCached,omitempty"` NFiles uint64 `json:"nFiles"` @@ -30,23 +33,23 @@ type simpleCacheItem struct { // EXISTING_CODE } -func (s *simpleCacheItem) String() string { +func (s *SimpleCacheItem) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleCacheItem) Raw() *types.RawModeler { +func (s *SimpleCacheItem) Raw() *RawModeler { return nil } -func (s *simpleCacheItem) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleCacheItem) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} // EXISTING_CODE // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } @@ -54,3 +57,6 @@ func (s *simpleCacheItem) Model(chain, format string, verbose bool, extraOptions // EXISTING_CODE // EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_metadata.go b/src/apps/chifra/pkg/types/types_metadata.go new file mode 100644 index 0000000000..541e78f08f --- /dev/null +++ b/src/apps/chifra/pkg/types/types_metadata.go @@ -0,0 +1,44 @@ +package types + +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" +) + +type MetaData struct { + Latest uint64 `json:"client"` + Finalized uint64 `json:"finalized"` + Staging uint64 `json:"staging"` + Ripe uint64 `json:"ripe"` + Unripe uint64 `json:"unripe"` + ChainId uint64 `json:"chainId,omitempty"` + NetworkId uint64 `json:"networkId,omitempty"` + Chain string `json:"chain,omitempty"` +} + +func (m *MetaData) String() string { + ret, _ := json.MarshalIndent(m, "", " ") + return string(ret) +} + +// Highest returns the height of the index (i.e., max between the finalized, staging, and ripe indexes). +func (m *MetaData) IndexHeight() base.Blknum { + return utils.Max(m.Finalized, utils.Max(m.Staging, m.Ripe)) +} + +// NextIndexHeight returns the block after the height of the index. +func (m *MetaData) NextIndexHeight() base.Blknum { + return m.IndexHeight() + 1 +} + +// ChainHeight returns the block after the height of the index. +func (m *MetaData) ChainHeight() base.Blknum { + return m.Latest +} + +// StageHieght returns the highest block that's been staged +func (m *MetaData) StageHeight() base.Blknum { + return m.Staging +} diff --git a/src/apps/chifra/pkg/types/types_status.go b/src/apps/chifra/pkg/types/types_status.go new file mode 100644 index 0000000000..db414c2752 --- /dev/null +++ b/src/apps/chifra/pkg/types/types_status.go @@ -0,0 +1,164 @@ +// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. +// Use of this source code is governed by a license that can +// be found in the LICENSE file. +/* + * Parts of this file were auto generated. Edit only those parts of + * the code inside of 'EXISTING_CODE' tags. + */ + +package types + +// EXISTING_CODE +import ( + "encoding/json" + "sort" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" +) + +// EXISTING_CODE + +type RawStatus struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleStatus struct { + CachePath string `json:"cachePath,omitempty"` + Caches []SimpleCacheItem `json:"caches"` + Chain string `json:"chain,omitempty"` + ChainConfig string `json:"chainConfig,omitempty"` + ChainId string `json:"chainId,omitempty"` + Chains []SimpleChain `json:"chains"` + ClientVersion string `json:"clientVersion,omitempty"` + HasEsKey bool `json:"hasEsKey,omitempty"` + HasPinKey bool `json:"hasPinKey,omitempty"` + IndexPath string `json:"indexPath,omitempty"` + IsApi bool `json:"isApi,omitempty"` + IsArchive bool `json:"isArchive,omitempty"` + IsScraping bool `json:"isScraping,omitempty"` + IsTesting bool `json:"isTesting,omitempty"` + IsTracing bool `json:"isTracing,omitempty"` + NetworkId string `json:"networkId,omitempty"` + Progress string `json:"progress,omitempty"` + RootConfig string `json:"rootConfig,omitempty"` + RpcProvider string `json:"rpcProvider,omitempty"` + Version string `json:"version,omitempty"` + + // EXISTING_CODE + Meta *MetaData `json:"meta,omitempty"` + Diffs *MetaData `json:"diffs,omitempty"` + // EXISTING_CODE +} + +func (s *SimpleStatus) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + +func (s *SimpleStatus) Raw() *RawModeler { + return nil +} + +func (s *SimpleStatus) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { + var model = map[string]interface{}{} + var order = []string{} + + // EXISTING_CODE + model = map[string]interface{}{ + "cachePath": s.CachePath, + "chainConfig": s.ChainConfig, + "clientVersion": s.ClientVersion, + "hasEsKey": s.HasEsKey, + "hasPinKey": s.HasPinKey, + "indexPath": s.IndexPath, + "isApi": s.IsApi, + "isArchive": s.IsArchive, + "isTesting": s.IsTesting, + "isTracing": s.IsTracing, + "rootConfig": s.RootConfig, + "rpcProvider": s.RpcProvider, + "trueblocksVersion": s.Version, + } + order = []string{ + "cachePath", + "chainConfig", + "clientVersion", + "hasEsKey", + "hasPinKey", + "indexPath", + "isApi", + "isArchive", + "isTesting", + "isTracing", + "rootConfig", + "rpcProvider", + "trueblocksVersion", + } + + if extraOptions != nil && extraOptions["showProgress"] == true { + model["progress"] = s.Progress + order = append(order, "progress") + } + + testMode := extraOptions["testMode"] == true + if len(s.Caches) > 0 { + if testMode { + for i := 0; i < len(s.Caches); i++ { + s.Caches[i].Path = "--paths--" + s.Caches[i].LastCached = "--lastCached--" + s.Caches[i].NFiles = 123 + s.Caches[i].NFolders = 456 + s.Caches[i].SizeInBytes = 789 + } + } + model["caches"] = s.Caches + order = append(order, "caches") + } + + if extraOptions["chains"] == true { + var chains []SimpleChain + if extraOptions["testMode"] == true { + ch := SimpleChain{ + Chain: "testChain", + ChainId: 12345, + LocalExplorer: "http://localhost:8080", + RpcProvider: "http://localhost:8545", + Symbol: "ETH", + } + chains = append(chains, ch) + } else { + chainArray := config.GetChains() + for _, chain := range chainArray { + ch := SimpleChain{ + Chain: chain.Chain, + ChainId: utils.MustParseUint(chain.ChainId), + LocalExplorer: chain.LocalExplorer, + RemoteExplorer: chain.RemoteExplorer, + RpcProvider: chain.RpcProvider, + IpfsGateway: chain.IpfsGateway, + Symbol: chain.Symbol, + } + chains = append(chains, ch) + } + sort.Slice(chains, func(i, j int) bool { + if chains[i].ChainId == chains[j].ChainId { + return chains[i].Chain < chains[j].Chain + } + return chains[i].ChainId < chains[j].ChainId + }) + } + model["chains"] = chains + order = append(order, "chains") + } + // EXISTING_CODE + + return Model{ + Data: model, + Order: order, + } +} + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml b/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml index 4376459a60..a39d21a724 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml @@ -5,4 +5,4 @@ doc_descr = "a single entry in the results of a status query when `--verbose` is enabled" doc_route = "430-cacheItem" produced_by = "status" - go_output = "src/apps/chifra/internal/status" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/status.toml b/src/dev_tools/goMaker/templates/classDefinitions/status.toml index 9289036a73..a8e77323ce 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/status.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/status.toml @@ -4,4 +4,4 @@ doc_descr = "status-related data about the TrueBlocks system including the server and local binary caches" doc_route = "403-status" produced_by = "status" - go_output = "src/apps/chifra/internal/status" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/sdk_go_route.go.tmpl b/src/dev_tools/goMaker/templates/sdk_go_route.go.tmpl index a9e20ae621..6b3e2cfa7b 100644 --- a/src/dev_tools/goMaker/templates/sdk_go_route.go.tmpl +++ b/src/dev_tools/goMaker/templates/sdk_go_route.go.tmpl @@ -57,7 +57,7 @@ func Get{{.Proper}}Options(args []string) (*{{.Proper}}Options, error) { return &opts, nil } -func (opts *{{.Proper}}Options) Query() ([]{{.Returns}}, *rpc.MetaData, error) { +func (opts *{{.Proper}}Options) Query() ([]{{.Returns}}, *types.MetaData, error) { buffer := bytes.Buffer{} if err := opts.{{.Proper}}(&buffer); err != nil { logger.Fatal(err) From 79f007a1f2c7954516bb84d9ec7ca9a4d9024cd2 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 10:55:00 -0400 Subject: [PATCH 04/18] Fixes build and regenerates --- .../chifra/internal/blocks/handle_count.go | 2 +- .../chifra/internal/monitors/handle_clean.go | 2 +- .../chifra/internal/status/handle_caches.go | 2 +- .../chifra/internal/status/handle_diagnose.go | 2 +- .../chifra/internal/status/handle_show.go | 2 +- .../chifra/internal/traces/handle_counts.go | 2 +- .../chifra/internal/when/handle_ts_count.go | 2 +- .../chifra/internal/when/handle_ts_show.go | 2 +- src/apps/chifra/pkg/types/types_blockcount.go | 25 +++++++++--- src/apps/chifra/pkg/types/types_cacheitem.go | 38 +++++++++++++------ .../chifra/pkg/types/types_monitorclean.go | 29 +++++++++----- src/apps/chifra/pkg/types/types_status.go | 36 ++++++++++++++++-- src/apps/chifra/pkg/types/types_timestamp.go | 20 +++++++--- .../chifra/pkg/types/types_timestampcount.go | 20 +++++++--- src/apps/chifra/pkg/types/types_tracecount.go | 22 ++++++++--- src/dev_tools/goMaker/types/types_member.go | 8 ---- 16 files changed, 153 insertions(+), 61 deletions(-) diff --git a/src/apps/chifra/internal/blocks/handle_count.go b/src/apps/chifra/internal/blocks/handle_count.go index 2d28b093cf..dea2efdbfa 100644 --- a/src/apps/chifra/internal/blocks/handle_count.go +++ b/src/apps/chifra/internal/blocks/handle_count.go @@ -18,7 +18,7 @@ func (opts *BlocksOptions) HandleCounts() error { chain := opts.Globals.Chain ctx, cancel := context.WithCancel(context.Background()) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawBlockCount], errorChan chan error) { for _, br := range opts.BlockIds { blockNums, err := br.ResolveBlocks(chain) if err != nil { diff --git a/src/apps/chifra/internal/monitors/handle_clean.go b/src/apps/chifra/internal/monitors/handle_clean.go index 5fb1269d97..405870f280 100644 --- a/src/apps/chifra/internal/monitors/handle_clean.go +++ b/src/apps/chifra/internal/monitors/handle_clean.go @@ -19,7 +19,7 @@ func (opts *MonitorsOptions) HandleClean() error { _, monArray := monitor.GetMonitorMap(chain) ctx := context.Background() - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawMonitorClean], errorChan chan error) { for _, mon := range monArray { addr := mon.Address.Hex() s := types.SimpleMonitorClean{ diff --git a/src/apps/chifra/internal/status/handle_caches.go b/src/apps/chifra/internal/status/handle_caches.go index 39977884c8..323b43fb0d 100644 --- a/src/apps/chifra/internal/status/handle_caches.go +++ b/src/apps/chifra/internal/status/handle_caches.go @@ -22,7 +22,7 @@ func (opts *StatusOptions) HandleCaches() error { testMode := opts.Globals.TestMode ctx := context.Background() - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawStatus], errorChan chan error) { now := time.Now() filenameChan := make(chan walk.CacheFileInfo) diff --git a/src/apps/chifra/internal/status/handle_diagnose.go b/src/apps/chifra/internal/status/handle_diagnose.go index addda0b6e0..a688d9a68b 100644 --- a/src/apps/chifra/internal/status/handle_diagnose.go +++ b/src/apps/chifra/internal/status/handle_diagnose.go @@ -12,7 +12,7 @@ func (opts *StatusOptions) HandleDiagnose() error { testMode := opts.Globals.TestMode ctx := context.Background() - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawStatus], errorChan chan error) { s, err := opts.GetSimpleStatus(opts.Diagnose) if err != nil { errorChan <- err diff --git a/src/apps/chifra/internal/status/handle_show.go b/src/apps/chifra/internal/status/handle_show.go index 504f7d3ee3..8fff58c922 100644 --- a/src/apps/chifra/internal/status/handle_show.go +++ b/src/apps/chifra/internal/status/handle_show.go @@ -22,7 +22,7 @@ func (opts *StatusOptions) HandleShow() error { testMode := opts.Globals.TestMode ctx := context.Background() - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawStatus], errorChan chan error) { s, err := opts.GetSimpleStatus(opts.Diagnose) if err != nil { errorChan <- err diff --git a/src/apps/chifra/internal/traces/handle_counts.go b/src/apps/chifra/internal/traces/handle_counts.go index cd1026b80d..8d9cad829f 100644 --- a/src/apps/chifra/internal/traces/handle_counts.go +++ b/src/apps/chifra/internal/traces/handle_counts.go @@ -22,7 +22,7 @@ func (opts *TracesOptions) HandleCounts() error { nErrors := 0 ctx, cancel := context.WithCancel(context.Background()) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawTraceCount], errorChan chan error) { apps, _, err := identifiers.IdsToApps(chain, opts.TransactionIds) if err != nil { errorChan <- err diff --git a/src/apps/chifra/internal/when/handle_ts_count.go b/src/apps/chifra/internal/when/handle_ts_count.go index 7c214db4b1..7df9d88711 100644 --- a/src/apps/chifra/internal/when/handle_ts_count.go +++ b/src/apps/chifra/internal/when/handle_ts_count.go @@ -17,7 +17,7 @@ func (opts *WhenOptions) HandleTimestampCount() error { testMode := opts.Globals.TestMode ctx := context.Background() - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawTimestampCount], errorChan chan error) { if count, err := tslib.NTimestamps(chain); err != nil { errorChan <- err return diff --git a/src/apps/chifra/internal/when/handle_ts_show.go b/src/apps/chifra/internal/when/handle_ts_show.go index 58f332eb8b..ac761b4b89 100644 --- a/src/apps/chifra/internal/when/handle_ts_show.go +++ b/src/apps/chifra/internal/when/handle_ts_show.go @@ -31,7 +31,7 @@ func (opts *WhenOptions) HandleTimestampsShow() error { ctx := context.Background() prev := base.Timestamp(0) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawTimestamp], errorChan chan error) { for bn := uint64(0); bn < cnt; bn++ { if len(bnMap) == 0 || bnMap[bn] { ts, err := tslib.FromBn(chain, bn) diff --git a/src/apps/chifra/pkg/types/types_blockcount.go b/src/apps/chifra/pkg/types/types_blockcount.go index fa85e3b4b3..937204bf6d 100644 --- a/src/apps/chifra/pkg/types/types_blockcount.go +++ b/src/apps/chifra/pkg/types/types_blockcount.go @@ -19,6 +19,14 @@ import ( // EXISTING_CODE type RawBlockCount struct { + AddressCnt string `json:"addressCnt"` + BlockNumber string `json:"blockNumber"` + LogsCnt string `json:"logsCnt"` + Timestamp string `json:"timestamp"` + TracesCnt string `json:"tracesCnt"` + TransactionsCnt string `json:"transactionsCnt"` + UnclesCnt string `json:"unclesCnt"` + WithdrawalsCnt string `json:"withdrawalsCnt"` // EXISTING_CODE // EXISTING_CODE } @@ -32,7 +40,7 @@ type SimpleBlockCount struct { TransactionsCnt uint64 `json:"transactionsCnt"` UnclesCnt uint64 `json:"unclesCnt,omitempty"` WithdrawalsCnt uint64 `json:"withdrawalsCnt,omitempty"` - + raw *RawBlockCount `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -42,8 +50,12 @@ func (s *SimpleBlockCount) String() string { return string(bytes) } -func (s *SimpleBlockCount) Raw() *RawModeler { - return nil +func (s *SimpleBlockCount) Raw() *RawBlockCount { + return s.raw +} + +func (s *SimpleBlockCount) SetRaw(raw *RawBlockCount) { + s.raw = raw } func (s *SimpleBlockCount) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -125,8 +137,11 @@ func (s *SimpleBlockCount) Date() string { return utils.FormattedDate(s.Timestamp) } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleBlockCount) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_cacheitem.go b/src/apps/chifra/pkg/types/types_cacheitem.go index 9a29095b12..cc8b6b5229 100644 --- a/src/apps/chifra/pkg/types/types_cacheitem.go +++ b/src/apps/chifra/pkg/types/types_cacheitem.go @@ -16,19 +16,26 @@ import ( // EXISTING_CODE type RawCacheItem struct { + Items []string `json:"items"` + LastCached string `json:"lastCached"` + NFiles string `json:"nFiles"` + NFolders string `json:"nFolders"` + Path string `json:"path"` + SizeInBytes string `json:"sizeInBytes"` + CacheItemType string `json:"type"` // EXISTING_CODE // EXISTING_CODE } type SimpleCacheItem struct { - Items []any `json:"items"` - LastCached string `json:"lastCached,omitempty"` - NFiles uint64 `json:"nFiles"` - NFolders uint64 `json:"nFolders"` - Path string `json:"path"` - SizeInBytes int64 `json:"sizeInBytes"` - CacheItemType string `json:"type"` - + Items []any `json:"items"` + LastCached string `json:"lastCached,omitempty"` + NFiles uint64 `json:"nFiles"` + NFolders uint64 `json:"nFolders"` + Path string `json:"path"` + SizeInBytes int64 `json:"sizeInBytes"` + CacheItemType string `json:"type"` + raw *RawCacheItem `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -38,8 +45,12 @@ func (s *SimpleCacheItem) String() string { return string(bytes) } -func (s *SimpleCacheItem) Raw() *RawModeler { - return nil +func (s *SimpleCacheItem) Raw() *RawCacheItem { + return s.raw +} + +func (s *SimpleCacheItem) SetRaw(raw *RawCacheItem) { + s.raw = raw } func (s *SimpleCacheItem) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -55,8 +66,11 @@ func (s *SimpleCacheItem) Model(chain, format string, verbose bool, extraOptions } } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleCacheItem) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_monitorclean.go b/src/apps/chifra/pkg/types/types_monitorclean.go index ce50e26c4d..d6ffa988d0 100644 --- a/src/apps/chifra/pkg/types/types_monitorclean.go +++ b/src/apps/chifra/pkg/types/types_monitorclean.go @@ -18,16 +18,20 @@ import ( // EXISTING_CODE type RawMonitorClean struct { + Address string `json:"address"` + Dups string `json:"dups"` + SizeNow string `json:"sizeNow"` + SizeThen string `json:"sizeThen"` // EXISTING_CODE // EXISTING_CODE } type SimpleMonitorClean struct { - Address base.Address `json:"address"` - Dups int64 `json:"dups"` - SizeNow int64 `json:"sizeNow"` - SizeThen int64 `json:"sizeThen"` - + Address base.Address `json:"address"` + Dups int64 `json:"dups"` + SizeNow int64 `json:"sizeNow"` + SizeThen int64 `json:"sizeThen"` + raw *RawMonitorClean `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -37,8 +41,12 @@ func (s *SimpleMonitorClean) String() string { return string(bytes) } -func (s *SimpleMonitorClean) Raw() *RawModeler { - return nil +func (s *SimpleMonitorClean) Raw() *RawMonitorClean { + return s.raw +} + +func (s *SimpleMonitorClean) SetRaw(raw *RawMonitorClean) { + s.raw = raw } func (s *SimpleMonitorClean) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -66,8 +74,11 @@ func (s *SimpleMonitorClean) Model(chain, format string, verbose bool, extraOpti } } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleMonitorClean) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_status.go b/src/apps/chifra/pkg/types/types_status.go index db414c2752..d78a02cf1c 100644 --- a/src/apps/chifra/pkg/types/types_status.go +++ b/src/apps/chifra/pkg/types/types_status.go @@ -20,6 +20,26 @@ import ( // EXISTING_CODE type RawStatus struct { + CachePath string `json:"cachePath"` + Caches []string `json:"caches"` + Chain string `json:"chain"` + ChainConfig string `json:"chainConfig"` + ChainId string `json:"chainId"` + Chains []string `json:"chains"` + ClientVersion string `json:"clientVersion"` + HasEsKey string `json:"hasEsKey"` + HasPinKey string `json:"hasPinKey"` + IndexPath string `json:"indexPath"` + IsApi string `json:"isApi"` + IsArchive string `json:"isArchive"` + IsScraping string `json:"isScraping"` + IsTesting string `json:"isTesting"` + IsTracing string `json:"isTracing"` + NetworkId string `json:"networkId"` + Progress string `json:"progress"` + RootConfig string `json:"rootConfig"` + RpcProvider string `json:"rpcProvider"` + Version string `json:"version"` // EXISTING_CODE // EXISTING_CODE } @@ -45,7 +65,7 @@ type SimpleStatus struct { RootConfig string `json:"rootConfig,omitempty"` RpcProvider string `json:"rpcProvider,omitempty"` Version string `json:"version,omitempty"` - + raw *RawStatus `json:"-"` // EXISTING_CODE Meta *MetaData `json:"meta,omitempty"` Diffs *MetaData `json:"diffs,omitempty"` @@ -57,8 +77,12 @@ func (s *SimpleStatus) String() string { return string(bytes) } -func (s *SimpleStatus) Raw() *RawModeler { - return nil +func (s *SimpleStatus) Raw() *RawStatus { + return s.raw +} + +func (s *SimpleStatus) SetRaw(raw *RawStatus) { + s.raw = raw } func (s *SimpleStatus) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -160,5 +184,11 @@ func (s *SimpleStatus) Model(chain, format string, verbose bool, extraOptions ma } } +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleStatus) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} + // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_timestamp.go b/src/apps/chifra/pkg/types/types_timestamp.go index 115ce4ef70..a5d88ab554 100644 --- a/src/apps/chifra/pkg/types/types_timestamp.go +++ b/src/apps/chifra/pkg/types/types_timestamp.go @@ -19,6 +19,9 @@ import ( // EXISTING_CODE type RawTimestamp struct { + BlockNumber string `json:"blockNumber"` + Diff string `json:"diff"` + Timestamp string `json:"timestamp"` // EXISTING_CODE // EXISTING_CODE } @@ -27,7 +30,7 @@ type SimpleTimestamp struct { BlockNumber base.Blknum `json:"blockNumber"` Diff int64 `json:"diff"` Timestamp base.Timestamp `json:"timestamp"` - + raw *RawTimestamp `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -37,8 +40,12 @@ func (s *SimpleTimestamp) String() string { return string(bytes) } -func (s *SimpleTimestamp) Raw() *RawModeler { - return nil +func (s *SimpleTimestamp) Raw() *RawTimestamp { + return s.raw +} + +func (s *SimpleTimestamp) SetRaw(raw *RawTimestamp) { + s.raw = raw } func (s *SimpleTimestamp) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -68,8 +75,11 @@ func (s *SimpleTimestamp) Date() string { return utils.FormattedDate(s.Timestamp) } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleTimestamp) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_timestampcount.go b/src/apps/chifra/pkg/types/types_timestampcount.go index 9dabbe9dc0..d63de9c808 100644 --- a/src/apps/chifra/pkg/types/types_timestampcount.go +++ b/src/apps/chifra/pkg/types/types_timestampcount.go @@ -16,13 +16,14 @@ import ( // EXISTING_CODE type RawTimestampCount struct { + Count string `json:"count"` // EXISTING_CODE // EXISTING_CODE } type SimpleTimestampCount struct { - Count uint64 `json:"count"` - + Count uint64 `json:"count"` + raw *RawTimestampCount `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -32,8 +33,12 @@ func (s *SimpleTimestampCount) String() string { return string(bytes) } -func (s *SimpleTimestampCount) Raw() *RawModeler { - return nil +func (s *SimpleTimestampCount) Raw() *RawTimestampCount { + return s.raw +} + +func (s *SimpleTimestampCount) SetRaw(raw *RawTimestampCount) { + s.raw = raw } func (s *SimpleTimestampCount) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -55,8 +60,11 @@ func (s *SimpleTimestampCount) Model(chain, format string, verbose bool, extraOp } } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleTimestampCount) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_tracecount.go b/src/apps/chifra/pkg/types/types_tracecount.go index 122b55b117..b9a78e3c2b 100644 --- a/src/apps/chifra/pkg/types/types_tracecount.go +++ b/src/apps/chifra/pkg/types/types_tracecount.go @@ -19,6 +19,11 @@ import ( // EXISTING_CODE type RawTraceCount struct { + BlockNumber string `json:"blockNumber"` + Timestamp string `json:"timestamp"` + TracesCnt string `json:"tracesCnt"` + TransactionHash string `json:"transactionHash"` + TransactionIndex string `json:"transactionIndex"` // EXISTING_CODE // EXISTING_CODE } @@ -29,7 +34,7 @@ type SimpleTraceCount struct { TracesCnt uint64 `json:"tracesCnt"` TransactionHash base.Hash `json:"transactionHash"` TransactionIndex base.Blknum `json:"transactionIndex"` - + raw *RawTraceCount `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -39,8 +44,12 @@ func (s *SimpleTraceCount) String() string { return string(bytes) } -func (s *SimpleTraceCount) Raw() *RawModeler { - return nil +func (s *SimpleTraceCount) Raw() *RawTraceCount { + return s.raw +} + +func (s *SimpleTraceCount) SetRaw(raw *RawTraceCount) { + s.raw = raw } func (s *SimpleTraceCount) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -74,8 +83,11 @@ func (s *SimpleTraceCount) Date() string { return utils.FormattedDate(s.Timestamp) } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleTraceCount) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/dev_tools/goMaker/types/types_member.go b/src/dev_tools/goMaker/types/types_member.go index a12a67cc98..5073c6cdd7 100644 --- a/src/dev_tools/goMaker/types/types_member.go +++ b/src/dev_tools/goMaker/types/types_member.go @@ -197,14 +197,6 @@ func (m *Member) GoType() string { return "[]Tx" } - if m.Container() == "Status" { - if m.Type == "CacheItem" { - return "[]simpleCacheItem" - } else if m.Type == "Chain" { - return "[]types.SimpleChain" - } - } - ret := m.Type if m.IsObject() { if m.GoName() != "TokenType" { From 37bdc33eec3c2e374c5913e292d97cff1fc50ce1 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 12:46:54 -0400 Subject: [PATCH 05/18] Moves ipfspina nd reportcheck to types --- .../chifra/internal/chunks/handle_check.go | 20 ++++++++--------- .../internal/chunks/handle_check_deep.go | 4 ++-- .../internal/chunks/handle_check_hashes.go | 5 +++-- .../internal/chunks/handle_check_internal.go | 7 +++--- .../internal/chunks/handle_check_manifest.go | 6 +++-- .../chunks/handle_check_sequential.go | 5 +++-- .../internal/chunks/handle_check_sizes.go | 3 ++- .../internal/chunks/handle_check_staging.go | 3 ++- .../internal/chunks/handle_check_version.go | 4 +++- .../chifra/internal/chunks/handle_list.go | 2 +- .../chunks => pkg/types}/types_ipfspin.go | 18 +++++++++------ .../chunks => pkg/types}/types_reportcheck.go | 22 ++++++++++++------- .../templates/classDefinitions/ipfspin.toml | 2 +- .../classDefinitions/reportcheck.toml | 2 +- 14 files changed, 61 insertions(+), 42 deletions(-) rename src/apps/chifra/{internal/chunks => pkg/types}/types_ipfspin.go (79%) rename src/apps/chifra/{internal/chunks => pkg/types}/types_reportcheck.go (81%) diff --git a/src/apps/chifra/internal/chunks/handle_check.go b/src/apps/chifra/internal/chunks/handle_check.go index f7391334d6..383f160eb0 100644 --- a/src/apps/chifra/internal/chunks/handle_check.go +++ b/src/apps/chifra/internal/chunks/handle_check.go @@ -121,63 +121,63 @@ func (opts *ChunksOptions) check(blockNums []uint64, silent bool) (error, bool) return remoteArray[i] < remoteArray[j] }) - reports := []simpleReportCheck{} + reports := []types.SimpleReportCheck{} allowMissing := config.GetScrape(chain).AllowMissing - seq := simpleReportCheck{Reason: "Filenames sequential"} + seq := types.SimpleReportCheck{Reason: "Filenames sequential"} if err := opts.CheckSequential(fileNames, cacheArray, remoteArray, allowMissing, &seq); err != nil { return err, false } reports = append(reports, seq) - intern := simpleReportCheck{Reason: "Internally consistent"} + intern := types.SimpleReportCheck{Reason: "Internally consistent"} if err := opts.CheckInternal(fileNames, blockNums, &intern); err != nil { return err, false } reports = append(reports, intern) - version := simpleReportCheck{Reason: "Correct version"} + version := types.SimpleReportCheck{Reason: "Correct version"} if err := opts.CheckVersion(fileNames, blockNums, &version); err != nil { return err, false } reports = append(reports, version) - con := simpleReportCheck{Reason: "Consistent hashes"} + con := types.SimpleReportCheck{Reason: "Consistent hashes"} if err := opts.CheckHashes(cacheManifest, remoteManifest, &con); err != nil { return err, false } reports = append(reports, con) - sizes := simpleReportCheck{Reason: "Check file sizes"} + sizes := types.SimpleReportCheck{Reason: "Check file sizes"} if err := opts.CheckSizes(fileNames, blockNums, cacheManifest, remoteManifest, &sizes); err != nil { return err, false } reports = append(reports, sizes) // compare with çached manifest with files on disc - d2c := simpleReportCheck{Reason: "Disc files to cached manifest"} + d2c := types.SimpleReportCheck{Reason: "Disc files to cached manifest"} if err := opts.CheckManifest(fnArray, cacheArray, &d2c); err != nil { return err, false } reports = append(reports, d2c) // compare with remote manifest with files on disc - d2r := simpleReportCheck{Reason: "Disc files to remote manifest"} + d2r := types.SimpleReportCheck{Reason: "Disc files to remote manifest"} if err := opts.CheckManifest(fnArray, remoteArray, &d2r); err != nil { return err, false } reports = append(reports, d2r) // compare remote manifest to cached manifest - r2c := simpleReportCheck{Reason: "Remote manifest to cached manifest"} + r2c := types.SimpleReportCheck{Reason: "Remote manifest to cached manifest"} if err := opts.CheckManifest(remoteArray, cacheArray, &r2c); err != nil { return err, false } reports = append(reports, r2c) if opts.Deep { - deep := simpleReportCheck{Reason: "Deep checks for " + opts.Mode} + deep := types.SimpleReportCheck{Reason: "Deep checks for " + opts.Mode} if err := opts.CheckDeep(cacheManifest, &deep); err != nil { return err, false } diff --git a/src/apps/chifra/internal/chunks/handle_check_deep.go b/src/apps/chifra/internal/chunks/handle_check_deep.go index ebd5d7c6d1..dacb4db901 100644 --- a/src/apps/chifra/internal/chunks/handle_check_deep.go +++ b/src/apps/chifra/internal/chunks/handle_check_deep.go @@ -25,7 +25,7 @@ import ( type reporter struct { chunk *types.SimpleChunkRecord - report *simpleReportCheck + report *types.SimpleReportCheck mutex *sync.Mutex } @@ -33,7 +33,7 @@ type reporter struct { // 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 (opts *ChunksOptions) CheckDeep(cacheMan *manifest.Manifest, report *simpleReportCheck) error { +func (opts *ChunksOptions) CheckDeep(cacheMan *manifest.Manifest, report *types.SimpleReportCheck) error { chain := opts.Globals.Chain testMode := opts.Globals.TestMode nErrors := 0 diff --git a/src/apps/chifra/internal/chunks/handle_check_hashes.go b/src/apps/chifra/internal/chunks/handle_check_hashes.go index 9cb6f25301..1a696bc14c 100644 --- a/src/apps/chifra/internal/chunks/handle_check_hashes.go +++ b/src/apps/chifra/internal/chunks/handle_check_hashes.go @@ -8,11 +8,12 @@ import ( "fmt" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/manifest" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // 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 (opts *ChunksOptions) CheckHashes(cacheMan *manifest.Manifest, contractMan *manifest.Manifest, report *simpleReportCheck) error { +func (opts *ChunksOptions) CheckHashes(cacheMan *manifest.Manifest, contractMan *manifest.Manifest, report *types.SimpleReportCheck) error { if err := opts.checkHashes("cache", cacheMan, report); err != nil { return err } @@ -24,7 +25,7 @@ func (opts *ChunksOptions) CheckHashes(cacheMan *manifest.Manifest, contractMan return nil } -func (opts *ChunksOptions) checkHashes(which string, man *manifest.Manifest, report *simpleReportCheck) error { +func (opts *ChunksOptions) checkHashes(which string, man *manifest.Manifest, report *types.SimpleReportCheck) error { for _, chunk := range man.Chunks { report.VisitedCnt++ report.CheckedCnt++ diff --git a/src/apps/chifra/internal/chunks/handle_check_internal.go b/src/apps/chifra/internal/chunks/handle_check_internal.go index 47285585a1..fc9316ed8e 100644 --- a/src/apps/chifra/internal/chunks/handle_check_internal.go +++ b/src/apps/chifra/internal/chunks/handle_check_internal.go @@ -12,12 +12,13 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) // 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 (opts *ChunksOptions) CheckInternal(fileNames []string, blockNums []uint64, report *simpleReportCheck) error { +func (opts *ChunksOptions) CheckInternal(fileNames []string, blockNums []uint64, report *types.SimpleReportCheck) error { for _, fileName := range fileNames { opts.checkIndexChunkInternal(fileName, false /* check version */, report) // opts.checkBloomInternal(testId, fileName, report) @@ -25,7 +26,7 @@ func (opts *ChunksOptions) CheckInternal(fileNames []string, blockNums []uint64, return nil } -func (opts *ChunksOptions) checkIndexChunkInternal(fileName string, checkVersion bool, report *simpleReportCheck) { +func (opts *ChunksOptions) checkIndexChunkInternal(fileName string, checkVersion bool, report *types.SimpleReportCheck) { report.VisitedCnt++ report.CheckedCnt++ @@ -50,7 +51,7 @@ func (opts *ChunksOptions) checkIndexChunkInternal(fileName string, checkVersion indexChunk.Close() } -func (opts *ChunksOptions) checkSnaps(fileName string, indexChunk *index.Index, report *simpleReportCheck) { +func (opts *ChunksOptions) checkSnaps(fileName string, indexChunk *index.Index, report *types.SimpleReportCheck) { report.VisitedCnt++ report.CheckedCnt++ diff --git a/src/apps/chifra/internal/chunks/handle_check_manifest.go b/src/apps/chifra/internal/chunks/handle_check_manifest.go index 61c65e2115..d06bdd5862 100644 --- a/src/apps/chifra/internal/chunks/handle_check_manifest.go +++ b/src/apps/chifra/internal/chunks/handle_check_manifest.go @@ -7,6 +7,8 @@ package chunksPkg import ( "fmt" "strings" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) type CompareState struct { @@ -23,7 +25,7 @@ type CompareState struct { // 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 *simpleReportCheck) error { +func (opts *ChunksOptions) CheckManifest(arrayA, arrayB []string, report *types.SimpleReportCheck) error { comp := CompareState{ testMode: opts.Globals.TestMode, details: opts.Globals.Verbose, @@ -45,7 +47,7 @@ func (opts *ChunksOptions) CheckManifest(arrayA, arrayB []string, report *simple } // TODO: Can this be made concurrent? -func (comp *CompareState) checkArrays(report *simpleReportCheck) error { +func (comp *CompareState) checkArrays(report *types.SimpleReportCheck) error { marker := "" if comp.testMode { marker = " (testing)" diff --git a/src/apps/chifra/internal/chunks/handle_check_sequential.go b/src/apps/chifra/internal/chunks/handle_check_sequential.go index 300b4d442d..6eb0d8d2af 100644 --- a/src/apps/chifra/internal/chunks/handle_check_sequential.go +++ b/src/apps/chifra/internal/chunks/handle_check_sequential.go @@ -8,6 +8,7 @@ import ( "fmt" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) @@ -16,7 +17,7 @@ import ( // 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 (opts *ChunksOptions) CheckSequential(fnArray, cacheArray, remoteArray []string, allowMissing bool, report *simpleReportCheck) error { +func (opts *ChunksOptions) CheckSequential(fnArray, cacheArray, remoteArray []string, allowMissing bool, report *types.SimpleReportCheck) error { if err := opts.checkSequential("disc", fnArray, allowMissing, report); err != nil { return err } @@ -33,7 +34,7 @@ func (opts *ChunksOptions) CheckSequential(fnArray, cacheArray, remoteArray []st } // TODO: Can this be made concurrent? -func (opts *ChunksOptions) checkSequential(which string, array []string, allowMissing bool, report *simpleReportCheck) error { +func (opts *ChunksOptions) checkSequential(which string, array []string, allowMissing bool, report *types.SimpleReportCheck) error { prev := base.NotARange for _, item := range array { var fR base.FileRange diff --git a/src/apps/chifra/internal/chunks/handle_check_sizes.go b/src/apps/chifra/internal/chunks/handle_check_sizes.go index c72c813639..4e5a3f155d 100644 --- a/src/apps/chifra/internal/chunks/handle_check_sizes.go +++ b/src/apps/chifra/internal/chunks/handle_check_sizes.go @@ -11,10 +11,11 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/manifest" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // CheckSizes compares the file on disc to the file size suggested in the manifest -func (opts *ChunksOptions) CheckSizes(fileNames []string, blockNums []uint64, cacheManifest *manifest.Manifest, remoteManifest *manifest.Manifest, report *simpleReportCheck) error { +func (opts *ChunksOptions) CheckSizes(fileNames []string, blockNums []uint64, cacheManifest *manifest.Manifest, remoteManifest *manifest.Manifest, report *types.SimpleReportCheck) error { // Figure out which manifest we're going to check against theManifest := cacheManifest diff --git a/src/apps/chifra/internal/chunks/handle_check_staging.go b/src/apps/chifra/internal/chunks/handle_check_staging.go index 41e0b6083d..f67eb534b2 100644 --- a/src/apps/chifra/internal/chunks/handle_check_staging.go +++ b/src/apps/chifra/internal/chunks/handle_check_staging.go @@ -13,6 +13,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // CheckStaging checks the staging file which should be names first-second.txt @@ -20,7 +21,7 @@ import ( // 2. Makes sure the first < last // 3. Makes sure that the first block inside is == first if allow_missing == false, > otherwise // 4. Makes sure that the last block inside is == last if allow_missing == false, < otherwise -func (opts *ChunksOptions) CheckStaging(lastBlock uint64, allow_missing bool, report *simpleReportCheck) error { +func (opts *ChunksOptions) CheckStaging(lastBlock uint64, allow_missing bool, report *types.SimpleReportCheck) error { chain := opts.Globals.Chain stagePath := index.ToStagingPath(config.PathToIndex(chain) + "staging") stageFn, _ := file.LatestFileInFolder(stagePath) diff --git a/src/apps/chifra/internal/chunks/handle_check_version.go b/src/apps/chifra/internal/chunks/handle_check_version.go index 0d781c5b88..20218825a7 100644 --- a/src/apps/chifra/internal/chunks/handle_check_version.go +++ b/src/apps/chifra/internal/chunks/handle_check_version.go @@ -4,9 +4,11 @@ package chunksPkg +import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" + // 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 (opts *ChunksOptions) CheckVersion(fileNames []string, blockNums []uint64, report *simpleReportCheck) error { +func (opts *ChunksOptions) CheckVersion(fileNames []string, blockNums []uint64, report *types.SimpleReportCheck) error { for _, fileName := range fileNames { opts.checkIndexChunkInternal(fileName, true /* checkVersion */, report) // opts.checkBloomInternal(testId, fileName, report) diff --git a/src/apps/chifra/internal/chunks/handle_list.go b/src/apps/chifra/internal/chunks/handle_list.go index 560a515eb9..7fcd0efb0a 100644 --- a/src/apps/chifra/internal/chunks/handle_list.go +++ b/src/apps/chifra/internal/chunks/handle_list.go @@ -32,7 +32,7 @@ func (opts *ChunksOptions) HandleList(unused []uint64) error { for _, line := range array { parts := strings.Split(line, "\t") if len(parts) == 5 { - s := simpleIpfsPin{ + s := types.SimpleIpfsPin{ Cid: base.IpfsHash(parts[0]), DatePinned: parts[1], FileName: parts[2], diff --git a/src/apps/chifra/internal/chunks/types_ipfspin.go b/src/apps/chifra/pkg/types/types_ipfspin.go similarity index 79% rename from src/apps/chifra/internal/chunks/types_ipfspin.go rename to src/apps/chifra/pkg/types/types_ipfspin.go index b7f0c77eb4..f26ba808e1 100644 --- a/src/apps/chifra/internal/chunks/types_ipfspin.go +++ b/src/apps/chifra/pkg/types/types_ipfspin.go @@ -6,7 +6,7 @@ * the code inside of 'EXISTING_CODE' tags. */ -package chunksPkg +package types // EXISTING_CODE import ( @@ -14,12 +14,16 @@ import ( "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // EXISTING_CODE -type simpleIpfsPin struct { +type RawIpfsPin struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleIpfsPin struct { Cid base.IpfsHash `json:"cid"` DatePinned string `json:"datePinned"` FileName string `json:"fileName"` @@ -30,16 +34,16 @@ type simpleIpfsPin struct { // EXISTING_CODE } -func (s *simpleIpfsPin) String() string { +func (s *SimpleIpfsPin) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleIpfsPin) Raw() *types.RawModeler { +func (s *SimpleIpfsPin) Raw() *RawModeler { return nil } -func (s *simpleIpfsPin) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleIpfsPin) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} @@ -60,7 +64,7 @@ func (s *simpleIpfsPin) Model(chain, format string, verbose bool, extraOptions m } // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } diff --git a/src/apps/chifra/internal/chunks/types_reportcheck.go b/src/apps/chifra/pkg/types/types_reportcheck.go similarity index 81% rename from src/apps/chifra/internal/chunks/types_reportcheck.go rename to src/apps/chifra/pkg/types/types_reportcheck.go index ba068cbb49..7756300765 100644 --- a/src/apps/chifra/internal/chunks/types_reportcheck.go +++ b/src/apps/chifra/pkg/types/types_reportcheck.go @@ -6,18 +6,21 @@ * the code inside of 'EXISTING_CODE' tags. */ -package chunksPkg +package types // EXISTING_CODE import ( "encoding/json" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // EXISTING_CODE -type simpleReportCheck struct { +type RawReportCheck struct { + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleReportCheck struct { CheckedCnt uint32 `json:"checkedCnt"` FailedCnt uint32 `json:"failedCnt"` MsgStrings []string `json:"msgStrings"` @@ -31,16 +34,16 @@ type simpleReportCheck struct { // EXISTING_CODE } -func (s *simpleReportCheck) String() string { +func (s *SimpleReportCheck) String() string { bytes, _ := json.Marshal(s) return string(bytes) } -func (s *simpleReportCheck) Raw() *types.RawModeler { +func (s *SimpleReportCheck) Raw() *RawModeler { return nil } -func (s *simpleReportCheck) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleReportCheck) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { var model = map[string]interface{}{} var order = []string{} @@ -77,7 +80,7 @@ func (s *simpleReportCheck) Model(chain, format string, verbose bool, extraOptio } // EXISTING_CODE - return types.Model{ + return Model{ Data: model, Order: order, } @@ -85,3 +88,6 @@ func (s *simpleReportCheck) Model(chain, format string, verbose bool, extraOptio // EXISTING_CODE // EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml b/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml index 743f9f4d88..993b8835e2 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml @@ -4,4 +4,4 @@ doc_descr = "internal-use only data model detailing a single remote or local ipfs pinned file" doc_route = "421-ipfsPin" produced_by = "chunks" - go_output = "src/apps/chifra/internal/chunks" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml b/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml index 147b3455ca..c48879590b 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml @@ -4,4 +4,4 @@ doc_descr = "report on checking contents of chunks" doc_route = "433-reportCheck" produced_by = "chunks" - go_output = "src/apps/chifra/internal/chunks" + go_output = "src/apps/chifra/pkg/types" From c8cda536d5bb5688264d5b6a90d0d5f7c4c80803 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 15:07:59 -0400 Subject: [PATCH 06/18] Fixes build --- .../chifra/internal/chunks/handle_check.go | 2 +- .../chifra/internal/chunks/handle_list.go | 2 +- src/apps/chifra/pkg/types/types_ipfspin.go | 21 ++++++++-- .../chifra/pkg/types/types_reportcheck.go | 41 +++++++++++++------ .../classDefinitions/chunkpinreport.toml | 2 +- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/apps/chifra/internal/chunks/handle_check.go b/src/apps/chifra/internal/chunks/handle_check.go index 383f160eb0..82971e41d2 100644 --- a/src/apps/chifra/internal/chunks/handle_check.go +++ b/src/apps/chifra/internal/chunks/handle_check.go @@ -197,7 +197,7 @@ func (opts *ChunksOptions) check(blockNums []uint64, silent bool) (error, bool) } ctx := context.Background() - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawReportCheck], errorChan chan error) { for _, report := range reports { if !silent { modelChan <- &report diff --git a/src/apps/chifra/internal/chunks/handle_list.go b/src/apps/chifra/internal/chunks/handle_list.go index 7fcd0efb0a..0f271ebcf9 100644 --- a/src/apps/chifra/internal/chunks/handle_list.go +++ b/src/apps/chifra/internal/chunks/handle_list.go @@ -21,7 +21,7 @@ func (opts *ChunksOptions) HandleList(unused []uint64) error { } ctx := context.Background() - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawIpfsPin], errorChan chan error) { var perPage = 1000 if testMode { perPage = -100 diff --git a/src/apps/chifra/pkg/types/types_ipfspin.go b/src/apps/chifra/pkg/types/types_ipfspin.go index f26ba808e1..3f340a7516 100644 --- a/src/apps/chifra/pkg/types/types_ipfspin.go +++ b/src/apps/chifra/pkg/types/types_ipfspin.go @@ -19,6 +19,11 @@ import ( // EXISTING_CODE type RawIpfsPin struct { + Cid string `json:"cid"` + DatePinned string `json:"datePinned"` + FileName string `json:"fileName"` + Size string `json:"size"` + Status string `json:"status"` // EXISTING_CODE // EXISTING_CODE } @@ -29,7 +34,7 @@ type SimpleIpfsPin struct { FileName string `json:"fileName"` Size int64 `json:"size"` Status string `json:"status"` - + raw *RawIpfsPin `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -39,8 +44,12 @@ func (s *SimpleIpfsPin) String() string { return string(bytes) } -func (s *SimpleIpfsPin) Raw() *RawModeler { - return nil +func (s *SimpleIpfsPin) Raw() *RawIpfsPin { + return s.raw +} + +func (s *SimpleIpfsPin) SetRaw(raw *RawIpfsPin) { + s.raw = raw } func (s *SimpleIpfsPin) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -70,6 +79,12 @@ func (s *SimpleIpfsPin) Model(chain, format string, verbose bool, extraOptions m } } +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleIpfsPin) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} + // EXISTING_CODE func cleanDate(date string) string { parts := strings.Split(date, ".") diff --git a/src/apps/chifra/pkg/types/types_reportcheck.go b/src/apps/chifra/pkg/types/types_reportcheck.go index 7756300765..57bc4e2610 100644 --- a/src/apps/chifra/pkg/types/types_reportcheck.go +++ b/src/apps/chifra/pkg/types/types_reportcheck.go @@ -16,20 +16,28 @@ import ( // EXISTING_CODE type RawReportCheck struct { + CheckedCnt string `json:"checkedCnt"` + FailedCnt string `json:"failedCnt"` + MsgStrings []string `json:"msgStrings"` + PassedCnt string `json:"passedCnt"` + Reason string `json:"reason"` + Result string `json:"result"` + SkippedCnt string `json:"skippedCnt"` + VisitedCnt string `json:"visitedCnt"` // EXISTING_CODE // EXISTING_CODE } type SimpleReportCheck struct { - CheckedCnt uint32 `json:"checkedCnt"` - FailedCnt uint32 `json:"failedCnt"` - MsgStrings []string `json:"msgStrings"` - PassedCnt uint32 `json:"passedCnt"` - Reason string `json:"reason"` - Result string `json:"result"` - SkippedCnt uint32 `json:"skippedCnt"` - VisitedCnt uint32 `json:"visitedCnt"` - + CheckedCnt uint32 `json:"checkedCnt"` + FailedCnt uint32 `json:"failedCnt"` + MsgStrings []string `json:"msgStrings"` + PassedCnt uint32 `json:"passedCnt"` + Reason string `json:"reason"` + Result string `json:"result"` + SkippedCnt uint32 `json:"skippedCnt"` + VisitedCnt uint32 `json:"visitedCnt"` + raw *RawReportCheck `json:"-"` // EXISTING_CODE // EXISTING_CODE } @@ -39,8 +47,12 @@ func (s *SimpleReportCheck) String() string { return string(bytes) } -func (s *SimpleReportCheck) Raw() *RawModeler { - return nil +func (s *SimpleReportCheck) Raw() *RawReportCheck { + return s.raw +} + +func (s *SimpleReportCheck) SetRaw(raw *RawReportCheck) { + s.raw = raw } func (s *SimpleReportCheck) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { @@ -86,8 +98,11 @@ func (s *SimpleReportCheck) Model(chain, format string, verbose bool, extraOptio } } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleReportCheck) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml index 31e57d1416..eeb7b63f21 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml @@ -4,4 +4,4 @@ doc_descr = "a JSON object containing the results of pinning the Unchained Index" doc_route = "436-chunkPinReport" produced_by = "chunks" - go_output = "src/apps/chifra/internal/chunks" + go_output = "src/apps/chifra/pkg/types" From fa90d18418b167c1fb144cf5c0345bd4a938b704 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 16:37:02 -0400 Subject: [PATCH 07/18] Fixing build --- .../chunks/handle_addresses_belongs.go | 22 +++++++++++++++++-- .../chifra/internal/chunks/handle_diff.go | 20 ++++++++++++++++- src/apps/chifra/internal/chunks/output.go | 2 +- .../internal/chunks/types_appearanceTable.go | 18 ++++++++++++--- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go index 778f1d4be6..7812d9022b 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go +++ b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go @@ -85,11 +85,29 @@ func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[ty break } - if s.Appearances, err = indexChunk.ReadAppearancesAndReset(&s.AddressRecord); err != nil { + var discApps []index.AppearanceRecord + discAddr := index.AddressRecord{ + Address: s.AddressRecord.Address, + Offset: s.AddressRecord.Offset, + Count: s.AddressRecord.Count, + } + if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { return false, err } + s.Appearances = make([]AppRecord, 0, len(discApps)) + for _, a := range discApps { + s.Appearances = append(s.Appearances, AppRecord{ + BlockNumber: uint32(a.BlockNumber), + TransactionIndex: uint32(a.TransactionIndex), + }) + } + s.AddressRecord = AddrRecord{ + Address: discAddr.Address, + Offset: discAddr.Offset, + Count: uint32(len(discApps)), + } if opts.FirstBlock != 0 || opts.LastBlock != utils.NOPOS { - good := []index.AppearanceRecord{} + good := []AppRecord{} for _, app := range s.Appearances { if uint64(app.BlockNumber) >= opts.FirstBlock && uint64(app.BlockNumber) <= opts.LastBlock { good = append(good, app) diff --git a/src/apps/chifra/internal/chunks/handle_diff.go b/src/apps/chifra/internal/chunks/handle_diff.go index bace82abc3..5e2e018ab0 100644 --- a/src/apps/chifra/internal/chunks/handle_diff.go +++ b/src/apps/chifra/internal/chunks/handle_diff.go @@ -109,9 +109,27 @@ func (opts *ChunksOptions) exportTo(dest, source string, rd base.RangeDiff) (boo if err := binary.Read(indexChunk.File, binary.LittleEndian, &s.AddressRecord); err != nil { return false, err } - if s.Appearances, err = indexChunk.ReadAppearancesAndReset(&s.AddressRecord); err != nil { + var discApps []index.AppearanceRecord + discAddr := index.AddressRecord{ + Address: s.AddressRecord.Address, + Offset: s.AddressRecord.Offset, + Count: s.AddressRecord.Count, + } + if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { return false, err } + s.Appearances = make([]AppRecord, 0, len(discApps)) + for _, a := range discApps { + s.Appearances = append(s.Appearances, AppRecord{ + BlockNumber: uint32(a.BlockNumber), + TransactionIndex: uint32(a.TransactionIndex), + }) + } + s.AddressRecord = AddrRecord{ + Address: discAddr.Address, + Offset: discAddr.Offset, + Count: uint32(len(discApps)), + } for _, app := range s.Appearances { apps = append(apps, types.SimpleAppearance{ Address: s.AddressRecord.Address, diff --git a/src/apps/chifra/internal/chunks/output.go b/src/apps/chifra/internal/chunks/output.go index 8fe5a25935..1d3387c202 100644 --- a/src/apps/chifra/internal/chunks/output.go +++ b/src/apps/chifra/internal/chunks/output.go @@ -135,7 +135,7 @@ func GetChunksOptions(args []string, g *globals.GlobalOptions) *ChunksOptions { } // EXISTING_CODE -func (opts *ChunksOptions) shouldShow(obj index.AddressRecord) bool { +func (opts *ChunksOptions) shouldShow(obj AddrRecord) bool { if opts.Mode == "addresses" || opts.Mode == "appearances" { return opts.Globals.Verbose } diff --git a/src/apps/chifra/internal/chunks/types_appearanceTable.go b/src/apps/chifra/internal/chunks/types_appearanceTable.go index 6f545e1bc5..6e51d97b0d 100644 --- a/src/apps/chifra/internal/chunks/types_appearanceTable.go +++ b/src/apps/chifra/internal/chunks/types_appearanceTable.go @@ -5,13 +5,25 @@ package chunksPkg import ( - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) +// AddrRecord is a single record in the Address table +type AddrRecord struct { + Address base.Address `json:"address"` + Offset uint32 `json:"offset"` + Count uint32 `json:"count"` +} + +type AppRecord struct { + BlockNumber uint32 `json:"blockNumber"` + TransactionIndex uint32 `json:"transactionIndex"` +} + type simpleAppearanceTable struct { - AddressRecord index.AddressRecord `json:"addressRecord"` - Appearances []index.AppearanceRecord `json:"appearances"` + AddressRecord AddrRecord `json:"addressRecord"` + Appearances []AppRecord `json:"appearances"` } func (s *simpleAppearanceTable) Raw() *types.RawModeler { From f3eb99fd70b34379c20908b81d94e2a24a07b840 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 17:00:19 -0400 Subject: [PATCH 08/18] Moves a few types out of internal --- .../internal/chunks/handle_addresses.go | 10 +- .../chifra/internal/chunks/handle_blooms.go | 4 +- .../chifra/internal/chunks/handle_index.go | 4 +- src/apps/chifra/internal/chunks/handle_pin.go | 4 +- src/apps/chifra/internal/chunks/output.go | 10 -- .../internal/chunks/types_chunkaddress.go | 66 ----------- .../internal/chunks/types_chunkbloom.go | 75 ------------- .../internal/chunks/types_chunkindex.go | 72 ------------ .../internal/chunks/types_chunkpinreport.go | 69 ------------ .../chifra/pkg/types/types_chunkaddress.go | 84 ++++++++++++++ src/apps/chifra/pkg/types/types_chunkbloom.go | 106 ++++++++++++++++++ src/apps/chifra/pkg/types/types_chunkindex.go | 92 +++++++++++++++ .../chifra/pkg/types/types_chunkpinreport.go | 88 +++++++++++++++ .../classDefinitions/chunkaddress.toml | 2 +- .../classDefinitions/chunkbloom.toml | 2 +- .../classDefinitions/chunkindex.toml | 2 +- 16 files changed, 384 insertions(+), 306 deletions(-) delete mode 100644 src/apps/chifra/internal/chunks/types_chunkaddress.go delete mode 100644 src/apps/chifra/internal/chunks/types_chunkbloom.go delete mode 100644 src/apps/chifra/internal/chunks/types_chunkindex.go delete mode 100644 src/apps/chifra/internal/chunks/types_chunkpinreport.go create mode 100644 src/apps/chifra/pkg/types/types_chunkaddress.go create mode 100644 src/apps/chifra/pkg/types/types_chunkbloom.go create mode 100644 src/apps/chifra/pkg/types/types_chunkindex.go create mode 100644 src/apps/chifra/pkg/types/types_chunkpinreport.go diff --git a/src/apps/chifra/internal/chunks/handle_addresses.go b/src/apps/chifra/internal/chunks/handle_addresses.go index c61dfde1c7..2f07a39d02 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses.go +++ b/src/apps/chifra/internal/chunks/handle_addresses.go @@ -23,12 +23,12 @@ func (opts *ChunksOptions) HandleAddresses(blockNums []uint64) error { chain := opts.Globals.Chain been_here := 0 ctx, cancel := context.WithCancel(context.Background()) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawChunkAddress], errorChan chan error) { var showAddresses func(walker *walk.CacheWalker, path string, first bool) (bool, error) if opts.Globals.Verbose { - showAddresses = func(walker *walk.CacheWalker, path string, first bool) (bool, error) { - return opts.handleResolvedRecords(modelChan, walker, path, first) - } + // showAddresses = func(walker *walk.CacheWalker, path string, first bool) (bool, error) { + // return opts.handleResolvedRecords(modelChan, walker, path, first) + // } } else { showAddresses = func(walker *walk.CacheWalker, path string, first bool) (bool, error) { if path != index.ToBloomPath(path) { @@ -74,7 +74,7 @@ func (opts *ChunksOptions) HandleAddresses(blockNums []uint64) error { return false, err } - s := simpleChunkAddress{ + s := types.SimpleChunkAddress{ Address: obj.Address, Range: indexChunk.Range.String(), Offset: uint64(obj.Offset), diff --git a/src/apps/chifra/internal/chunks/handle_blooms.go b/src/apps/chifra/internal/chunks/handle_blooms.go index b3fca8170c..ae2d6ae9fc 100644 --- a/src/apps/chifra/internal/chunks/handle_blooms.go +++ b/src/apps/chifra/internal/chunks/handle_blooms.go @@ -20,7 +20,7 @@ func (opts *ChunksOptions) HandleBlooms(blockNums []uint64) error { chain := opts.Globals.Chain ctx, cancel := context.WithCancel(context.Background()) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawChunkBloom], errorChan chan error) { showBloom := func(walker *walk.CacheWalker, path string, first bool) (bool, error) { if path != index.ToBloomPath(path) { return false, fmt.Errorf("should not happen in showBloom") @@ -42,7 +42,7 @@ func (opts *ChunksOptions) HandleBlooms(blockNums []uint64) error { return false, err } - s := simpleChunkBloom{ + s := types.SimpleChunkBloom{ Magic: fmt.Sprintf("0x%x", bl.Header.Magic), Hash: bl.Header.Hash, Size: stats.BloomSz, diff --git a/src/apps/chifra/internal/chunks/handle_index.go b/src/apps/chifra/internal/chunks/handle_index.go index d38c5543da..ebc270a8cd 100644 --- a/src/apps/chifra/internal/chunks/handle_index.go +++ b/src/apps/chifra/internal/chunks/handle_index.go @@ -23,7 +23,7 @@ func (opts *ChunksOptions) HandleIndex(blockNums []uint64) error { chain := opts.Globals.Chain ctx, cancel := context.WithCancel(context.Background()) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawChunkIndex], errorChan chan error) { showIndex := func(walker *walk.CacheWalker, fileName string, first bool) (bool, error) { if fileName != index.ToBloomPath(fileName) { return false, fmt.Errorf("should not happen in showIndex") @@ -46,7 +46,7 @@ func (opts *ChunksOptions) HandleIndex(blockNums []uint64) error { return false, err } - s := simpleChunkIndex{ + s := types.SimpleChunkIndex{ Range: rng.String(), Magic: fmt.Sprintf("0x%x", indexChunk.Header.Magic), Hash: indexChunk.Header.Hash, diff --git a/src/apps/chifra/internal/chunks/handle_pin.go b/src/apps/chifra/internal/chunks/handle_pin.go index 619abbab97..ab0e5109f6 100644 --- a/src/apps/chifra/internal/chunks/handle_pin.go +++ b/src/apps/chifra/internal/chunks/handle_pin.go @@ -52,9 +52,9 @@ func (opts *ChunksOptions) HandlePin(blockNums []uint64) error { } ctx, cancel := context.WithCancel(context.Background()) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawChunkPinReport], errorChan chan error) { hash := base.BytesToHash(config.HeaderHash(config.ExpectedVersion())) - report := simpleChunkPinReport{ + report := types.SimpleChunkPinReport{ Version: config.VersionTags[hash.Hex()], Chain: chain, SpecHash: base.IpfsHash(manifest.Specification()), diff --git a/src/apps/chifra/internal/chunks/output.go b/src/apps/chifra/internal/chunks/output.go index 1d3387c202..0955a80679 100644 --- a/src/apps/chifra/internal/chunks/output.go +++ b/src/apps/chifra/internal/chunks/output.go @@ -14,8 +14,6 @@ import ( "os" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/internal/globals" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/identifiers" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" @@ -148,14 +146,6 @@ func (opts *ChunksOptions) shouldShow(obj AddrRecord) bool { return false } -func FormattedTag(verbose bool, hash base.Hash) string { - if tag, ok := config.VersionTags[hash.Hex()]; !ok { - return utils.FormattedHash(verbose, hash.Hex()) - } else { - return tag - } -} - func GetChunkStats(chain, path string) (s types.SimpleChunkStats, err error) { chunk, err := index.OpenChunk(path, true /* check */) if err != nil && !os.IsNotExist(err) { diff --git a/src/apps/chifra/internal/chunks/types_chunkaddress.go b/src/apps/chifra/internal/chunks/types_chunkaddress.go deleted file mode 100644 index ebbdc14f7f..0000000000 --- a/src/apps/chifra/internal/chunks/types_chunkaddress.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. -// Use of this source code is governed by a license that can -// be found in the LICENSE file. -/* - * Parts of this file were auto generated. Edit only those parts of - * the code inside of 'EXISTING_CODE' tags. - */ - -package chunksPkg - -// EXISTING_CODE -import ( - "encoding/json" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" -) - -// EXISTING_CODE - -type simpleChunkAddress struct { - Address base.Address `json:"address"` - Count uint64 `json:"count"` - Offset uint64 `json:"offset"` - Range string `json:"range"` - - // EXISTING_CODE - // EXISTING_CODE -} - -func (s *simpleChunkAddress) String() string { - bytes, _ := json.Marshal(s) - return string(bytes) -} - -func (s *simpleChunkAddress) Raw() *types.RawModeler { - return nil -} - -func (s *simpleChunkAddress) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { - var model = map[string]interface{}{} - var order = []string{} - - // EXISTING_CODE - model = map[string]interface{}{ - "address": s.Address, - "range": s.Range, - "offset": s.Offset, - "count": s.Count, - } - order = []string{ - "address", - "range", - "offset", - "count", - } - // EXISTING_CODE - - return types.Model{ - Data: model, - Order: order, - } -} - -// EXISTING_CODE -// EXISTING_CODE diff --git a/src/apps/chifra/internal/chunks/types_chunkbloom.go b/src/apps/chifra/internal/chunks/types_chunkbloom.go deleted file mode 100644 index f26550898b..0000000000 --- a/src/apps/chifra/internal/chunks/types_chunkbloom.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. -// Use of this source code is governed by a license that can -// be found in the LICENSE file. -/* - * Parts of this file were auto generated. Edit only those parts of - * the code inside of 'EXISTING_CODE' tags. - */ - -package chunksPkg - -// EXISTING_CODE -import ( - "encoding/json" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" -) - -// EXISTING_CODE - -type simpleChunkBloom struct { - ByteWidth uint64 `json:"byteWidth"` - Hash base.Hash `json:"hash"` - Magic string `json:"magic"` - NBlooms uint64 `json:"nBlooms"` - NInserted uint64 `json:"nInserted"` - Range string `json:"range"` - Size uint64 `json:"size"` - - // EXISTING_CODE - // EXISTING_CODE -} - -func (s *simpleChunkBloom) String() string { - bytes, _ := json.Marshal(s) - return string(bytes) -} - -func (s *simpleChunkBloom) Raw() *types.RawModeler { - return nil -} - -func (s *simpleChunkBloom) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { - var model = map[string]interface{}{} - var order = []string{} - - // EXISTING_CODE - model = map[string]interface{}{ - "range": s.Range, - "magic": s.Magic, - "hash": FormattedTag(verbose, s.Hash), - "nBlooms": s.NBlooms, - "nInserted": s.NInserted, - "size": s.Size, - "byteWidth": s.ByteWidth, - } - order = []string{ - "range", - "magic", - "hash", - "nBlooms", - "nInserted", - "size", - "byteWidth", - } - // EXISTING_CODE - - return types.Model{ - Data: model, - Order: order, - } -} - -// EXISTING_CODE -// EXISTING_CODE diff --git a/src/apps/chifra/internal/chunks/types_chunkindex.go b/src/apps/chifra/internal/chunks/types_chunkindex.go deleted file mode 100644 index 17aa68df8a..0000000000 --- a/src/apps/chifra/internal/chunks/types_chunkindex.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. -// Use of this source code is governed by a license that can -// be found in the LICENSE file. -/* - * Parts of this file were auto generated. Edit only those parts of - * the code inside of 'EXISTING_CODE' tags. - */ - -package chunksPkg - -// EXISTING_CODE -import ( - "encoding/json" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" -) - -// EXISTING_CODE - -type simpleChunkIndex struct { - Hash base.Hash `json:"hash"` - Magic string `json:"magic"` - NAddresses uint64 `json:"nAddresses"` - NAppearances uint64 `json:"nAppearances"` - Range string `json:"range"` - Size uint64 `json:"size"` - - // EXISTING_CODE - // EXISTING_CODE -} - -func (s *simpleChunkIndex) String() string { - bytes, _ := json.Marshal(s) - return string(bytes) -} - -func (s *simpleChunkIndex) Raw() *types.RawModeler { - return nil -} - -func (s *simpleChunkIndex) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { - var model = map[string]interface{}{} - var order = []string{} - - // EXISTING_CODE - model = map[string]interface{}{ - "range": s.Range, - "magic": s.Magic, - "hash": FormattedTag(verbose, s.Hash), - "nAddresses": s.NAddresses, - "nAppearances": s.NAppearances, - "fileSize": s.Size, - } - order = []string{ - "range", - "magic", - "hash", - "nAddresses", - "nAppearances", - "fileSize", - } - // EXISTING_CODE - - return types.Model{ - Data: model, - Order: order, - } -} - -// EXISTING_CODE -// EXISTING_CODE diff --git a/src/apps/chifra/internal/chunks/types_chunkpinreport.go b/src/apps/chifra/internal/chunks/types_chunkpinreport.go deleted file mode 100644 index 5c6606fab5..0000000000 --- a/src/apps/chifra/internal/chunks/types_chunkpinreport.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. -// Use of this source code is governed by a license that can -// be found in the LICENSE file. -/* - * Parts of this file were auto generated. Edit only those parts of - * the code inside of 'EXISTING_CODE' tags. - */ - -package chunksPkg - -// EXISTING_CODE -import ( - "encoding/json" - - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" -) - -// EXISTING_CODE - -type simpleChunkPinReport struct { - Chain string `json:"chain"` - ManifestHash base.IpfsHash `json:"manifestHash"` - SpecHash base.IpfsHash `json:"specHash"` - TimestampHash base.IpfsHash `json:"timestampHash"` - Version string `json:"version"` - - // EXISTING_CODE - // EXISTING_CODE -} - -func (s *simpleChunkPinReport) String() string { - bytes, _ := json.Marshal(s) - return string(bytes) -} - -func (s *simpleChunkPinReport) Raw() *types.RawModeler { - return nil -} - -func (s *simpleChunkPinReport) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { - var model = map[string]interface{}{} - var order = []string{} - - // EXISTING_CODE - model = map[string]interface{}{ - "chain": s.Chain, - "version": s.Version, - "manifestHash": s.ManifestHash, - "timestampHash": s.TimestampHash, - "specHash": s.SpecHash, - } - order = []string{ - "chain", - "version", - "manifestHash", - "timestampHash", - "specHash", - } - // EXISTING_CODE - - return types.Model{ - Data: model, - Order: order, - } -} - -// EXISTING_CODE -// EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkaddress.go b/src/apps/chifra/pkg/types/types_chunkaddress.go new file mode 100644 index 0000000000..9a1858dce5 --- /dev/null +++ b/src/apps/chifra/pkg/types/types_chunkaddress.go @@ -0,0 +1,84 @@ +// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. +// Use of this source code is governed by a license that can +// be found in the LICENSE file. +/* + * Parts of this file were auto generated. Edit only those parts of + * the code inside of 'EXISTING_CODE' tags. + */ + +package types + +// EXISTING_CODE +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" +) + +// EXISTING_CODE + +type RawChunkAddress struct { + Address string `json:"address"` + Count string `json:"count"` + Offset string `json:"offset"` + Range string `json:"range"` + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleChunkAddress struct { + Address base.Address `json:"address"` + Count uint64 `json:"count"` + Offset uint64 `json:"offset"` + Range string `json:"range"` + raw *RawChunkAddress `json:"-"` + // EXISTING_CODE + // EXISTING_CODE +} + +func (s *SimpleChunkAddress) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + +func (s *SimpleChunkAddress) Raw() *RawChunkAddress { + return s.raw +} + +func (s *SimpleChunkAddress) SetRaw(raw *RawChunkAddress) { + s.raw = raw +} + +func (s *SimpleChunkAddress) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { + var model = map[string]interface{}{} + var order = []string{} + + // EXISTING_CODE + model = map[string]interface{}{ + "address": s.Address, + "range": s.Range, + "offset": s.Offset, + "count": s.Count, + } + order = []string{ + "address", + "range", + "offset", + "count", + } + // EXISTING_CODE + + return Model{ + Data: model, + Order: order, + } +} + +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleChunkAddress) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkbloom.go b/src/apps/chifra/pkg/types/types_chunkbloom.go new file mode 100644 index 0000000000..62361f75bf --- /dev/null +++ b/src/apps/chifra/pkg/types/types_chunkbloom.go @@ -0,0 +1,106 @@ +// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. +// Use of this source code is governed by a license that can +// be found in the LICENSE file. +/* + * Parts of this file were auto generated. Edit only those parts of + * the code inside of 'EXISTING_CODE' tags. + */ + +package types + +// EXISTING_CODE +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" +) + +// EXISTING_CODE + +type RawChunkBloom struct { + ByteWidth string `json:"byteWidth"` + Hash string `json:"hash"` + Magic string `json:"magic"` + NBlooms string `json:"nBlooms"` + NInserted string `json:"nInserted"` + Range string `json:"range"` + Size string `json:"size"` + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleChunkBloom struct { + ByteWidth uint64 `json:"byteWidth"` + Hash base.Hash `json:"hash"` + Magic string `json:"magic"` + NBlooms uint64 `json:"nBlooms"` + NInserted uint64 `json:"nInserted"` + Range string `json:"range"` + Size uint64 `json:"size"` + raw *RawChunkBloom `json:"-"` + // EXISTING_CODE + // EXISTING_CODE +} + +func (s *SimpleChunkBloom) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + +func (s *SimpleChunkBloom) Raw() *RawChunkBloom { + return s.raw +} + +func (s *SimpleChunkBloom) SetRaw(raw *RawChunkBloom) { + s.raw = raw +} + +func (s *SimpleChunkBloom) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { + var model = map[string]interface{}{} + var order = []string{} + + // EXISTING_CODE + model = map[string]interface{}{ + "range": s.Range, + "magic": s.Magic, + "hash": FormattedTag(verbose, s.Hash), + "nBlooms": s.NBlooms, + "nInserted": s.NInserted, + "size": s.Size, + "byteWidth": s.ByteWidth, + } + order = []string{ + "range", + "magic", + "hash", + "nBlooms", + "nInserted", + "size", + "byteWidth", + } + // EXISTING_CODE + + return Model{ + Data: model, + Order: order, + } +} + +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleChunkBloom) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} + +// EXISTING_CODE +func FormattedTag(verbose bool, hash base.Hash) string { + if tag, ok := config.VersionTags[hash.Hex()]; !ok { + return utils.FormattedHash(verbose, hash.Hex()) + } else { + return tag + } +} + +// EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkindex.go b/src/apps/chifra/pkg/types/types_chunkindex.go new file mode 100644 index 0000000000..ca06f1cf1d --- /dev/null +++ b/src/apps/chifra/pkg/types/types_chunkindex.go @@ -0,0 +1,92 @@ +// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. +// Use of this source code is governed by a license that can +// be found in the LICENSE file. +/* + * Parts of this file were auto generated. Edit only those parts of + * the code inside of 'EXISTING_CODE' tags. + */ + +package types + +// EXISTING_CODE +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" +) + +// EXISTING_CODE + +type RawChunkIndex struct { + Hash string `json:"hash"` + Magic string `json:"magic"` + NAddresses string `json:"nAddresses"` + NAppearances string `json:"nAppearances"` + Range string `json:"range"` + Size string `json:"size"` + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleChunkIndex struct { + Hash base.Hash `json:"hash"` + Magic string `json:"magic"` + NAddresses uint64 `json:"nAddresses"` + NAppearances uint64 `json:"nAppearances"` + Range string `json:"range"` + Size uint64 `json:"size"` + raw *RawChunkIndex `json:"-"` + // EXISTING_CODE + // EXISTING_CODE +} + +func (s *SimpleChunkIndex) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + +func (s *SimpleChunkIndex) Raw() *RawChunkIndex { + return s.raw +} + +func (s *SimpleChunkIndex) SetRaw(raw *RawChunkIndex) { + s.raw = raw +} + +func (s *SimpleChunkIndex) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { + var model = map[string]interface{}{} + var order = []string{} + + // EXISTING_CODE + model = map[string]interface{}{ + "range": s.Range, + "magic": s.Magic, + "hash": FormattedTag(verbose, s.Hash), + "nAddresses": s.NAddresses, + "nAppearances": s.NAppearances, + "fileSize": s.Size, + } + order = []string{ + "range", + "magic", + "hash", + "nAddresses", + "nAppearances", + "fileSize", + } + // EXISTING_CODE + + return Model{ + Data: model, + Order: order, + } +} + +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleChunkIndex) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/apps/chifra/pkg/types/types_chunkpinreport.go b/src/apps/chifra/pkg/types/types_chunkpinreport.go new file mode 100644 index 0000000000..50d366948a --- /dev/null +++ b/src/apps/chifra/pkg/types/types_chunkpinreport.go @@ -0,0 +1,88 @@ +// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. +// Use of this source code is governed by a license that can +// be found in the LICENSE file. +/* + * Parts of this file were auto generated. Edit only those parts of + * the code inside of 'EXISTING_CODE' tags. + */ + +package types + +// EXISTING_CODE +import ( + "encoding/json" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" +) + +// EXISTING_CODE + +type RawChunkPinReport struct { + Chain string `json:"chain"` + ManifestHash string `json:"manifestHash"` + SpecHash string `json:"specHash"` + TimestampHash string `json:"timestampHash"` + Version string `json:"version"` + // EXISTING_CODE + // EXISTING_CODE +} + +type SimpleChunkPinReport struct { + Chain string `json:"chain"` + ManifestHash base.IpfsHash `json:"manifestHash"` + SpecHash base.IpfsHash `json:"specHash"` + TimestampHash base.IpfsHash `json:"timestampHash"` + Version string `json:"version"` + raw *RawChunkPinReport `json:"-"` + // EXISTING_CODE + // EXISTING_CODE +} + +func (s *SimpleChunkPinReport) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + +func (s *SimpleChunkPinReport) Raw() *RawChunkPinReport { + return s.raw +} + +func (s *SimpleChunkPinReport) SetRaw(raw *RawChunkPinReport) { + s.raw = raw +} + +func (s *SimpleChunkPinReport) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { + var model = map[string]interface{}{} + var order = []string{} + + // EXISTING_CODE + model = map[string]interface{}{ + "chain": s.Chain, + "version": s.Version, + "manifestHash": s.ManifestHash, + "timestampHash": s.TimestampHash, + "specHash": s.SpecHash, + } + order = []string{ + "chain", + "version", + "manifestHash", + "timestampHash", + "specHash", + } + // EXISTING_CODE + + return Model{ + Data: model, + Order: order, + } +} + +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleChunkPinReport) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml index 5db40576c0..ce94cc428e 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml @@ -4,4 +4,4 @@ doc_descr = "internal-use only data model detailing a single address record in the address table of an index chunk" doc_route = "418-chunkAddress" produced_by = "chunks" - go_output = "src/apps/chifra/internal/chunks" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml index 6e48d802b2..e9b7541b6d 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml @@ -4,4 +4,4 @@ doc_descr = "internal-use only data model detailing a single bloom filter file" doc_route = "415-chunkBloom" produced_by = "chunks" - go_output = "src/apps/chifra/internal/chunks" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml index 3adc6e53f5..75e256372a 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml @@ -4,4 +4,4 @@ doc_descr = "internal-use only data model detailing a single index chunk file" doc_route = "412-chunkIndex" produced_by = "chunks" - go_output = "src/apps/chifra/internal/chunks" + go_output = "src/apps/chifra/pkg/types" From 15bc1f0c10f0d72755e0970675610569951a30ee Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 17:13:20 -0400 Subject: [PATCH 09/18] Upper case AppearanceTable --- src/apps/chifra/internal/chunks/handle_addresses_belongs.go | 2 +- src/apps/chifra/internal/chunks/handle_diff.go | 2 +- src/apps/chifra/internal/chunks/types_appearanceTable.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go index 7812d9022b..4a18c5b4ad 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go +++ b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go @@ -75,7 +75,7 @@ func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[ty continue } - s := simpleAppearanceTable{} + s := SimpleAppearanceTable{} if err := binary.Read(indexChunk.File, binary.LittleEndian, &s.AddressRecord); err != nil { return false, err } diff --git a/src/apps/chifra/internal/chunks/handle_diff.go b/src/apps/chifra/internal/chunks/handle_diff.go index 5e2e018ab0..b8131655bc 100644 --- a/src/apps/chifra/internal/chunks/handle_diff.go +++ b/src/apps/chifra/internal/chunks/handle_diff.go @@ -105,7 +105,7 @@ func (opts *ChunksOptions) exportTo(dest, source string, rd base.RangeDiff) (boo apps := make([]types.SimpleAppearance, 0, 500000) for i := 0; i < int(indexChunk.Header.AddressCount); i++ { - s := simpleAppearanceTable{} + s := SimpleAppearanceTable{} if err := binary.Read(indexChunk.File, binary.LittleEndian, &s.AddressRecord); err != nil { return false, err } diff --git a/src/apps/chifra/internal/chunks/types_appearanceTable.go b/src/apps/chifra/internal/chunks/types_appearanceTable.go index 6e51d97b0d..2a1ee5c488 100644 --- a/src/apps/chifra/internal/chunks/types_appearanceTable.go +++ b/src/apps/chifra/internal/chunks/types_appearanceTable.go @@ -21,16 +21,16 @@ type AppRecord struct { TransactionIndex uint32 `json:"transactionIndex"` } -type simpleAppearanceTable struct { +type SimpleAppearanceTable struct { AddressRecord AddrRecord `json:"addressRecord"` Appearances []AppRecord `json:"appearances"` } -func (s *simpleAppearanceTable) Raw() *types.RawModeler { +func (s *SimpleAppearanceTable) Raw() *types.RawModeler { return nil } -func (s *simpleAppearanceTable) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { +func (s *SimpleAppearanceTable) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { return types.Model{ Data: map[string]any{ "address": s.AddressRecord.Address.Hex(), From 34441813cba033d8231644c29844cde81ec64942 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 17:51:05 -0400 Subject: [PATCH 10/18] Moved the last type to pkg --- .../internal/chunks/handle_addresses.go | 6 +- .../chunks/handle_addresses_belongs.go | 103 ++++++++++++++++-- .../chifra/internal/chunks/handle_diff.go | 8 +- src/apps/chifra/internal/chunks/output.go | 2 +- .../types}/types_appearanceTable.go | 33 +++++- .../classDefinitions/appearancetable.toml | 8 ++ .../fields/appearancetable.csv | 3 + 7 files changed, 142 insertions(+), 21 deletions(-) rename src/apps/chifra/{internal/chunks => pkg/types}/types_appearanceTable.go (66%) create mode 100644 src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml create mode 100644 src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv diff --git a/src/apps/chifra/internal/chunks/handle_addresses.go b/src/apps/chifra/internal/chunks/handle_addresses.go index 2f07a39d02..57d7891353 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses.go +++ b/src/apps/chifra/internal/chunks/handle_addresses.go @@ -26,9 +26,9 @@ func (opts *ChunksOptions) HandleAddresses(blockNums []uint64) error { fetchData := func(modelChan chan types.Modeler[types.RawChunkAddress], errorChan chan error) { var showAddresses func(walker *walk.CacheWalker, path string, first bool) (bool, error) if opts.Globals.Verbose { - // showAddresses = func(walker *walk.CacheWalker, path string, first bool) (bool, error) { - // return opts.handleResolvedRecords(modelChan, walker, path, first) - // } + showAddresses = func(walker *walk.CacheWalker, path string, first bool) (bool, error) { + return opts.handleResolvedRecords1(modelChan, walker, path, first) + } } else { showAddresses = func(walker *walk.CacheWalker, path string, first bool) (bool, error) { if path != index.ToBloomPath(path) { diff --git a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go index 4a18c5b4ad..6a02129785 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go +++ b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go @@ -23,7 +23,7 @@ func (opts *ChunksOptions) HandleIndexBelongs(blockNums []uint64) error { chain := opts.Globals.Chain ctx, cancel := context.WithCancel(context.Background()) - fetchData := func(modelChan chan types.Modeler[types.RawModeler], errorChan chan error) { + fetchData := func(modelChan chan types.Modeler[types.RawAppearanceTable], errorChan chan error) { showAddressesBelongs := func(walker *walk.CacheWalker, path string, first bool) (bool, error) { return opts.handleResolvedRecords(modelChan, walker, path, first) } @@ -47,7 +47,7 @@ func (opts *ChunksOptions) HandleIndexBelongs(blockNums []uint64) error { // handleResolvedRecords is a helper function for HandleIndexBelongs and verbose versions of // HandleAddresses and HandleAppearances. It is called once for each chunk in the index and // depends on the values of opts.Globals.Verbose and opts.Belongs. -func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[types.RawModeler], walker *walk.CacheWalker, path string, first bool) (bool, error) { +func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[types.RawAppearanceTable], walker *walk.CacheWalker, path string, first bool) (bool, error) { if path != index.ToBloomPath(path) { return false, fmt.Errorf("should not happen in showAddressesBelongs") } @@ -75,7 +75,7 @@ func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[ty continue } - s := SimpleAppearanceTable{} + s := types.SimpleAppearanceTable{} if err := binary.Read(indexChunk.File, binary.LittleEndian, &s.AddressRecord); err != nil { return false, err } @@ -94,20 +94,20 @@ func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[ty if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { return false, err } - s.Appearances = make([]AppRecord, 0, len(discApps)) + s.Appearances = make([]types.AppRecord, 0, len(discApps)) for _, a := range discApps { - s.Appearances = append(s.Appearances, AppRecord{ + s.Appearances = append(s.Appearances, types.AppRecord{ BlockNumber: uint32(a.BlockNumber), TransactionIndex: uint32(a.TransactionIndex), }) } - s.AddressRecord = AddrRecord{ + s.AddressRecord = types.AddrRecord{ Address: discAddr.Address, Offset: discAddr.Offset, Count: uint32(len(discApps)), } if opts.FirstBlock != 0 || opts.LastBlock != utils.NOPOS { - good := []AppRecord{} + good := []types.AppRecord{} for _, app := range s.Appearances { if uint64(app.BlockNumber) >= opts.FirstBlock && uint64(app.BlockNumber) <= opts.LastBlock { good = append(good, app) @@ -126,3 +126,92 @@ func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[ty return true, nil } + +// handleResolvedRecords1 is a helper function for HandleIndexBelongs and verbose versions of +// HandleAddresses and HandleAppearances. It is called once for each chunk in the index and +// depends on the values of opts.Globals.Verbose and opts.Belongs. +func (opts *ChunksOptions) handleResolvedRecords1(modelChan chan types.Modeler[types.RawChunkAddress], walker *walk.CacheWalker, path string, first bool) (bool, error) { + if path != index.ToBloomPath(path) { + return false, fmt.Errorf("should not happen in showAddressesBelongs") + } + + path = index.ToIndexPath(path) + if !file.FileExists(path) { + // Bloom files exist, but index files don't. It's okay. + return true, nil + } + + indexChunk, err := index.OpenIndex(path, true /* check */) + if err != nil { + return false, err + } + defer indexChunk.Close() + + _, err = indexChunk.File.Seek(int64(index.HeaderWidth), io.SeekStart) + if err != nil { + return false, err + } + + cnt := 0 + for i := 0; i < int(indexChunk.Header.AddressCount); i++ { + if opts.Globals.TestMode && i > walker.MaxTests() { + continue + } + + s := types.SimpleAppearanceTable{} + if err := binary.Read(indexChunk.File, binary.LittleEndian, &s.AddressRecord); err != nil { + return false, err + } + + if opts.shouldShow(s.AddressRecord) { + if uint64(cnt) >= opts.MaxAddrs { + break + } + + var discApps []index.AppearanceRecord + discAddr := index.AddressRecord{ + Address: s.AddressRecord.Address, + Offset: s.AddressRecord.Offset, + Count: s.AddressRecord.Count, + } + if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { + return false, err + } + s.Appearances = make([]types.AppRecord, 0, len(discApps)) + for _, a := range discApps { + s.Appearances = append(s.Appearances, types.AppRecord{ + BlockNumber: uint32(a.BlockNumber), + TransactionIndex: uint32(a.TransactionIndex), + }) + } + s.AddressRecord = types.AddrRecord{ + Address: discAddr.Address, + Offset: discAddr.Offset, + Count: uint32(len(discApps)), + } + if opts.FirstBlock != 0 || opts.LastBlock != utils.NOPOS { + good := []types.AppRecord{} + for _, app := range s.Appearances { + if uint64(app.BlockNumber) >= opts.FirstBlock && uint64(app.BlockNumber) <= opts.LastBlock { + good = append(good, app) + } + } + s.Appearances = good + s.AddressRecord.Count = uint32(len(good)) + } + if len(s.Appearances) == 0 { + continue + } + ss := types.SimpleChunkAddress{ + Address: s.AddressRecord.Address, + Count: uint64(s.AddressRecord.Count), + Offset: uint64(s.AddressRecord.Offset), + // Range string `json:"range"` + } + modelChan <- &ss + cnt++ + } + } + + return true, nil +} diff --git a/src/apps/chifra/internal/chunks/handle_diff.go b/src/apps/chifra/internal/chunks/handle_diff.go index b8131655bc..25f631238e 100644 --- a/src/apps/chifra/internal/chunks/handle_diff.go +++ b/src/apps/chifra/internal/chunks/handle_diff.go @@ -105,7 +105,7 @@ func (opts *ChunksOptions) exportTo(dest, source string, rd base.RangeDiff) (boo apps := make([]types.SimpleAppearance, 0, 500000) for i := 0; i < int(indexChunk.Header.AddressCount); i++ { - s := SimpleAppearanceTable{} + s := types.SimpleAppearanceTable{} if err := binary.Read(indexChunk.File, binary.LittleEndian, &s.AddressRecord); err != nil { return false, err } @@ -118,14 +118,14 @@ func (opts *ChunksOptions) exportTo(dest, source string, rd base.RangeDiff) (boo if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { return false, err } - s.Appearances = make([]AppRecord, 0, len(discApps)) + s.Appearances = make([]types.AppRecord, 0, len(discApps)) for _, a := range discApps { - s.Appearances = append(s.Appearances, AppRecord{ + s.Appearances = append(s.Appearances, types.AppRecord{ BlockNumber: uint32(a.BlockNumber), TransactionIndex: uint32(a.TransactionIndex), }) } - s.AddressRecord = AddrRecord{ + s.AddressRecord = types.AddrRecord{ Address: discAddr.Address, Offset: discAddr.Offset, Count: uint32(len(discApps)), diff --git a/src/apps/chifra/internal/chunks/output.go b/src/apps/chifra/internal/chunks/output.go index 0955a80679..2c14a5bd25 100644 --- a/src/apps/chifra/internal/chunks/output.go +++ b/src/apps/chifra/internal/chunks/output.go @@ -133,7 +133,7 @@ func GetChunksOptions(args []string, g *globals.GlobalOptions) *ChunksOptions { } // EXISTING_CODE -func (opts *ChunksOptions) shouldShow(obj AddrRecord) bool { +func (opts *ChunksOptions) shouldShow(obj types.AddrRecord) bool { if opts.Mode == "addresses" || opts.Mode == "appearances" { return opts.Globals.Verbose } diff --git a/src/apps/chifra/internal/chunks/types_appearanceTable.go b/src/apps/chifra/pkg/types/types_appearanceTable.go similarity index 66% rename from src/apps/chifra/internal/chunks/types_appearanceTable.go rename to src/apps/chifra/pkg/types/types_appearanceTable.go index 2a1ee5c488..a6b04cc9b6 100644 --- a/src/apps/chifra/internal/chunks/types_appearanceTable.go +++ b/src/apps/chifra/pkg/types/types_appearanceTable.go @@ -2,14 +2,13 @@ // Use of this source code is governed by a license that can // be found in the LICENSE file. -package chunksPkg +package types +// EXISTING_CODE import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) -// AddrRecord is a single record in the Address table type AddrRecord struct { Address base.Address `json:"address"` Offset uint32 `json:"offset"` @@ -21,17 +20,32 @@ type AppRecord struct { TransactionIndex uint32 `json:"transactionIndex"` } +// EXISTING_CODE + +type RawAppearanceTable struct { + // EXISTING_CODE + // EXISTING_CODE +} + type SimpleAppearanceTable struct { AddressRecord AddrRecord `json:"addressRecord"` Appearances []AppRecord `json:"appearances"` + raw *RawAppearanceTable + // EXISTING_CODE + // EXISTING_CODE } -func (s *SimpleAppearanceTable) Raw() *types.RawModeler { +func (s *SimpleAppearanceTable) Raw() *RawAppearanceTable { return nil } -func (s *SimpleAppearanceTable) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { - return types.Model{ +func (s *SimpleAppearanceTable) SetRaw(r *RawAppearanceTable) { + s.raw = r +} + +func (s *SimpleAppearanceTable) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { + // EXISTING_CODE + return Model{ Data: map[string]any{ "address": s.AddressRecord.Address.Hex(), "offset": s.AddressRecord.Offset, @@ -45,4 +59,11 @@ func (s *SimpleAppearanceTable) Model(chain, format string, verbose bool, extraO "appearances", }, } + // EXISTING_CODE } + +// EXISTING_CODE +// EXISTING_CODE + +// EXISTING_CODE +// EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml b/src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml new file mode 100644 index 0000000000..349828439f --- /dev/null +++ b/src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml @@ -0,0 +1,8 @@ +[settings] + class = "CAppearanceTable" + contained_by = "Monitor" + doc_group = "01-Accounts" + doc_descr = "an appearance table for an address" + doc_route = "103-appearanceTable" + produced_by = "chunks" + go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv new file mode 100644 index 0000000000..e2c1bd0f28 --- /dev/null +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv @@ -0,0 +1,3 @@ +name ,type ,strDefault ,attributes ,docOrder ,description +AddressRecord ,AddrRecord , , , 1 ,the address record for these appearances +Appearances ,AppRecord , , , 2 ,all the appearances for this address From 95c4aed7b95cbdb067406262f75a79c345a486eb Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 18:03:02 -0400 Subject: [PATCH 11/18] Fixing build --- docs/content/api/openapi.yaml | 17 ++++- docs/content/chifra/admin.md | 1 + docs/content/data-model/accounts.md | 15 ++++ src/apps/chifra/internal/chunks/README.md | 1 + .../chunks/handle_addresses_belongs.go | 16 ++--- .../chifra/internal/chunks/handle_diff.go | 6 +- src/apps/chifra/internal/chunks/output.go | 2 +- .../chifra/pkg/types/types_appearanceTable.go | 70 ++++++++++++------- .../fields/appearancetable.csv | 2 +- 9 files changed, 92 insertions(+), 38 deletions(-) diff --git a/docs/content/api/openapi.yaml b/docs/content/api/openapi.yaml index c40a7caffe..7c7a9078fe 100644 --- a/docs/content/api/openapi.yaml +++ b/docs/content/api/openapi.yaml @@ -2690,11 +2690,12 @@ paths: schema: properties: data: - description: Produces Appearance, ChunkAddress, ChunkBloom, ChunkIndex, ChunkPinReport, ChunkRecord, ChunkStats, IpfsPin, Manifest or ReportCheck data. Corresponds to the chifra chunks command line. + description: Produces Appearance, AppearanceTable, ChunkAddress, ChunkBloom, ChunkIndex, ChunkPinReport, ChunkRecord, ChunkStats, IpfsPin, Manifest or ReportCheck data. Corresponds to the chifra chunks command line. type: array items: oneOf: - $ref: "#/components/schemas/appearance" + - $ref: "#/components/schemas/appearanceTable" - $ref: "#/components/schemas/chunkAddress" - $ref: "#/components/schemas/chunkBloom" - $ref: "#/components/schemas/chunkIndex" @@ -3011,6 +3012,20 @@ components: type: string format: datetime description: "the timestamp as a date (calculated)" + appearanceTable: + description: "an appearance table for an address" + type: object + properties: + AddressRecord: + type: object + items: + $ref: "#/components/schemas/addrRecord" + description: "the address record for these appearances" + Appearances: + type: object + items: + $ref: "#/components/schemas/appRecord" + description: "all the appearances for this address" monitor: description: "a local file indicating a user's interest in an address. Includes caches for reconicilations, transactions, and appearances as well as an optional association to named account" type: object diff --git a/docs/content/chifra/admin.md b/docs/content/chifra/admin.md index 9e6afe9e5e..4eef49e7ea 100644 --- a/docs/content/chifra/admin.md +++ b/docs/content/chifra/admin.md @@ -342,6 +342,7 @@ Notes: Data models produced by this tool: - [appearance](/data-model/accounts/#appearance) +- [appearancetable](/data-model/accounts/#appearancetable) - [chunkaddress](/data-model/admin/#chunkaddress) - [chunkbloom](/data-model/admin/#chunkbloom) - [chunkindex](/data-model/admin/#chunkindex) diff --git a/docs/content/data-model/accounts.md b/docs/content/data-model/accounts.md index c53b2e9454..ef213977bc 100644 --- a/docs/content/data-model/accounts.md +++ b/docs/content/data-model/accounts.md @@ -58,6 +58,21 @@ Appearances consist of the following fields: | timestamp | the timestamp for this appearance | timestamp | | date | the timestamp as a date (calculated) | datetime | +## AppearanceTable + + + +The following commands produce and manage AppearanceTables: + +- [chifra chunks](/chifra/admin/#chifra-chunks) + +AppearanceTables consist of the following fields: + +| Field | Description | Type | +| ------------- | ---------------------------------------- | ---------- | +| AddressRecord | the address record for these appearances | AddrRecord | +| Appearances | all the appearances for this address | AppRecord | + ## Monitor A Monitor is a list of [Appearances](/data-model/accounts/#appearance) associated with a given diff --git a/src/apps/chifra/internal/chunks/README.md b/src/apps/chifra/internal/chunks/README.md index 12fedcf7ea..c4f040d87c 100644 --- a/src/apps/chifra/internal/chunks/README.md +++ b/src/apps/chifra/internal/chunks/README.md @@ -51,6 +51,7 @@ Notes: Data models produced by this tool: - [appearance](/data-model/accounts/#appearance) +- [appearancetable](/data-model/accounts/#appearancetable) - [chunkaddress](/data-model/admin/#chunkaddress) - [chunkbloom](/data-model/admin/#chunkbloom) - [chunkindex](/data-model/admin/#chunkindex) diff --git a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go index 6a02129785..7e735b668d 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go +++ b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go @@ -94,20 +94,20 @@ func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[ty if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { return false, err } - s.Appearances = make([]types.AppRecord, 0, len(discApps)) + s.Appearances = make([]types.SimpleAppRecord, 0, len(discApps)) for _, a := range discApps { - s.Appearances = append(s.Appearances, types.AppRecord{ + s.Appearances = append(s.Appearances, types.SimpleAppRecord{ BlockNumber: uint32(a.BlockNumber), TransactionIndex: uint32(a.TransactionIndex), }) } - s.AddressRecord = types.AddrRecord{ + s.AddressRecord = types.SimpleAddrRecord{ Address: discAddr.Address, Offset: discAddr.Offset, Count: uint32(len(discApps)), } if opts.FirstBlock != 0 || opts.LastBlock != utils.NOPOS { - good := []types.AppRecord{} + good := []types.SimpleAppRecord{} for _, app := range s.Appearances { if uint64(app.BlockNumber) >= opts.FirstBlock && uint64(app.BlockNumber) <= opts.LastBlock { good = append(good, app) @@ -177,20 +177,20 @@ func (opts *ChunksOptions) handleResolvedRecords1(modelChan chan types.Modeler[t if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { return false, err } - s.Appearances = make([]types.AppRecord, 0, len(discApps)) + s.Appearances = make([]types.SimpleAppRecord, 0, len(discApps)) for _, a := range discApps { - s.Appearances = append(s.Appearances, types.AppRecord{ + s.Appearances = append(s.Appearances, types.SimpleAppRecord{ BlockNumber: uint32(a.BlockNumber), TransactionIndex: uint32(a.TransactionIndex), }) } - s.AddressRecord = types.AddrRecord{ + s.AddressRecord = types.SimpleAddrRecord{ Address: discAddr.Address, Offset: discAddr.Offset, Count: uint32(len(discApps)), } if opts.FirstBlock != 0 || opts.LastBlock != utils.NOPOS { - good := []types.AppRecord{} + good := []types.SimpleAppRecord{} for _, app := range s.Appearances { if uint64(app.BlockNumber) >= opts.FirstBlock && uint64(app.BlockNumber) <= opts.LastBlock { good = append(good, app) diff --git a/src/apps/chifra/internal/chunks/handle_diff.go b/src/apps/chifra/internal/chunks/handle_diff.go index 25f631238e..9c6dfafa00 100644 --- a/src/apps/chifra/internal/chunks/handle_diff.go +++ b/src/apps/chifra/internal/chunks/handle_diff.go @@ -118,14 +118,14 @@ func (opts *ChunksOptions) exportTo(dest, source string, rd base.RangeDiff) (boo if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { return false, err } - s.Appearances = make([]types.AppRecord, 0, len(discApps)) + s.Appearances = []types.SimpleAppRecord{} for _, a := range discApps { - s.Appearances = append(s.Appearances, types.AppRecord{ + s.Appearances = append(s.Appearances, types.SimpleAppRecord{ BlockNumber: uint32(a.BlockNumber), TransactionIndex: uint32(a.TransactionIndex), }) } - s.AddressRecord = types.AddrRecord{ + s.AddressRecord = types.SimpleAddrRecord{ Address: discAddr.Address, Offset: discAddr.Offset, Count: uint32(len(discApps)), diff --git a/src/apps/chifra/internal/chunks/output.go b/src/apps/chifra/internal/chunks/output.go index 2c14a5bd25..f80d04c61a 100644 --- a/src/apps/chifra/internal/chunks/output.go +++ b/src/apps/chifra/internal/chunks/output.go @@ -133,7 +133,7 @@ func GetChunksOptions(args []string, g *globals.GlobalOptions) *ChunksOptions { } // EXISTING_CODE -func (opts *ChunksOptions) shouldShow(obj types.AddrRecord) bool { +func (opts *ChunksOptions) shouldShow(obj types.SimpleAddrRecord) bool { if opts.Mode == "addresses" || opts.Mode == "appearances" { return opts.Globals.Verbose } diff --git a/src/apps/chifra/pkg/types/types_appearanceTable.go b/src/apps/chifra/pkg/types/types_appearanceTable.go index a6b04cc9b6..b0a7a0a442 100644 --- a/src/apps/chifra/pkg/types/types_appearanceTable.go +++ b/src/apps/chifra/pkg/types/types_appearanceTable.go @@ -1,21 +1,27 @@ -// Copyright 2021 The TrueBlocks Authors. All rights reserved. +// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. // Use of this source code is governed by a license that can // be found in the LICENSE file. +/* + * Parts of this file were auto generated. Edit only those parts of + * the code inside of 'EXISTING_CODE' tags. + */ package types // EXISTING_CODE import ( + "encoding/json" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" ) -type AddrRecord struct { +type SimpleAddrRecord struct { Address base.Address `json:"address"` Offset uint32 `json:"offset"` Count uint32 `json:"count"` } -type AppRecord struct { +type SimpleAppRecord struct { BlockNumber uint32 `json:"blockNumber"` TransactionIndex uint32 `json:"transactionIndex"` } @@ -23,47 +29,63 @@ type AppRecord struct { // EXISTING_CODE type RawAppearanceTable struct { + AddressRecord string `json:"AddressRecord"` + Appearances string `json:"Appearances"` // EXISTING_CODE // EXISTING_CODE } type SimpleAppearanceTable struct { - AddressRecord AddrRecord `json:"addressRecord"` - Appearances []AppRecord `json:"appearances"` - raw *RawAppearanceTable + AddressRecord SimpleAddrRecord `json:"addressRecord"` + Appearances []SimpleAppRecord `json:"appearances"` + raw *RawAppearanceTable `json:"-"` // EXISTING_CODE // EXISTING_CODE } +func (s *SimpleAppearanceTable) String() string { + bytes, _ := json.Marshal(s) + return string(bytes) +} + func (s *SimpleAppearanceTable) Raw() *RawAppearanceTable { - return nil + return s.raw } -func (s *SimpleAppearanceTable) SetRaw(r *RawAppearanceTable) { - s.raw = r +func (s *SimpleAppearanceTable) SetRaw(raw *RawAppearanceTable) { + s.raw = raw } func (s *SimpleAppearanceTable) Model(chain, format string, verbose bool, extraOptions map[string]any) Model { + var model = map[string]interface{}{} + var order = []string{} + // EXISTING_CODE - return Model{ - Data: map[string]any{ - "address": s.AddressRecord.Address.Hex(), - "offset": s.AddressRecord.Offset, - "count": s.AddressRecord.Count, - "appearances": s.Appearances, - }, - Order: []string{ - "address", - "offset", - "count", - "appearances", - }, + model = map[string]any{ + "address": s.AddressRecord.Address.Hex(), + "offset": s.AddressRecord.Offset, + "count": s.AddressRecord.Count, + "appearances": s.Appearances, + } + order = []string{ + "address", + "offset", + "count", + "appearances", } // EXISTING_CODE + + return Model{ + Data: model, + Order: order, + } } -// EXISTING_CODE -// EXISTING_CODE +// FinishUnmarshal is used by the cache. It may be unused depending on auto-code-gen +func (s *SimpleAppearanceTable) FinishUnmarshal() { + // EXISTING_CODE + // EXISTING_CODE +} // EXISTING_CODE // EXISTING_CODE diff --git a/src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv b/src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv index e2c1bd0f28..bad6920699 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv +++ b/src/dev_tools/goMaker/templates/classDefinitions/fields/appearancetable.csv @@ -1,3 +1,3 @@ name ,type ,strDefault ,attributes ,docOrder ,description AddressRecord ,AddrRecord , , , 1 ,the address record for these appearances -Appearances ,AppRecord , , , 2 ,all the appearances for this address +Appearances ,[]AppRecord , , , 2 ,all the appearances for this address From 31eaf9ad86ec31fcd4f9fa786cd1613758f67757 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 20:02:24 -0400 Subject: [PATCH 12/18] Trying to remove index.AddressRecord and index.AppearanceRecord as dups --- .../internal/chunks/handle_addresses.go | 2 +- .../chunks/handle_addresses_belongs.go | 42 ++----------------- .../internal/chunks/handle_check_deep.go | 2 +- .../chifra/internal/chunks/handle_diff.go | 21 +--------- .../chifra/pkg/index/appearance_result.go | 13 +++++- src/apps/chifra/pkg/index/chunk_write.go | 5 ++- .../chifra/pkg/index/index_address_record.go | 12 ++---- .../pkg/index/index_appearance_record.go | 8 ++-- 8 files changed, 30 insertions(+), 75 deletions(-) diff --git a/src/apps/chifra/internal/chunks/handle_addresses.go b/src/apps/chifra/internal/chunks/handle_addresses.go index 57d7891353..0d706d9e31 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses.go +++ b/src/apps/chifra/internal/chunks/handle_addresses.go @@ -69,7 +69,7 @@ func (opts *ChunksOptions) HandleAddresses(blockNums []uint64) error { continue } - obj := index.AddressRecord{} + obj := types.SimpleAddrRecord{} if err := binary.Read(indexChunk.File, binary.LittleEndian, &obj); err != nil { return false, err } diff --git a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go index 7e735b668d..7bf270be07 100644 --- a/src/apps/chifra/internal/chunks/handle_addresses_belongs.go +++ b/src/apps/chifra/internal/chunks/handle_addresses_belongs.go @@ -85,27 +85,10 @@ func (opts *ChunksOptions) handleResolvedRecords(modelChan chan types.Modeler[ty break } - var discApps []index.AppearanceRecord - discAddr := index.AddressRecord{ - Address: s.AddressRecord.Address, - Offset: s.AddressRecord.Offset, - Count: s.AddressRecord.Count, - } - if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { + if s.Appearances, err = indexChunk.ReadAppearancesAndReset(&s.AddressRecord); err != nil { return false, err } - s.Appearances = make([]types.SimpleAppRecord, 0, len(discApps)) - for _, a := range discApps { - s.Appearances = append(s.Appearances, types.SimpleAppRecord{ - BlockNumber: uint32(a.BlockNumber), - TransactionIndex: uint32(a.TransactionIndex), - }) - } - s.AddressRecord = types.SimpleAddrRecord{ - Address: discAddr.Address, - Offset: discAddr.Offset, - Count: uint32(len(discApps)), - } + s.AddressRecord.Count = uint32(len(s.Appearances)) if opts.FirstBlock != 0 || opts.LastBlock != utils.NOPOS { good := []types.SimpleAppRecord{} for _, app := range s.Appearances { @@ -168,27 +151,10 @@ func (opts *ChunksOptions) handleResolvedRecords1(modelChan chan types.Modeler[t break } - var discApps []index.AppearanceRecord - discAddr := index.AddressRecord{ - Address: s.AddressRecord.Address, - Offset: s.AddressRecord.Offset, - Count: s.AddressRecord.Count, - } - if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { + if s.Appearances, err = indexChunk.ReadAppearancesAndReset(&s.AddressRecord); err != nil { return false, err } - s.Appearances = make([]types.SimpleAppRecord, 0, len(discApps)) - for _, a := range discApps { - s.Appearances = append(s.Appearances, types.SimpleAppRecord{ - BlockNumber: uint32(a.BlockNumber), - TransactionIndex: uint32(a.TransactionIndex), - }) - } - s.AddressRecord = types.SimpleAddrRecord{ - Address: discAddr.Address, - Offset: discAddr.Offset, - Count: uint32(len(discApps)), - } + s.AddressRecord.Count = uint32(len(s.Appearances)) if opts.FirstBlock != 0 || opts.LastBlock != utils.NOPOS { good := []types.SimpleAppRecord{} for _, app := range s.Appearances { diff --git a/src/apps/chifra/internal/chunks/handle_check_deep.go b/src/apps/chifra/internal/chunks/handle_check_deep.go index dacb4db901..4b7a977947 100644 --- a/src/apps/chifra/internal/chunks/handle_check_deep.go +++ b/src/apps/chifra/internal/chunks/handle_check_deep.go @@ -79,7 +79,7 @@ func (opts *ChunksOptions) CheckDeep(cacheMan *manifest.Manifest, report *types. } for i := 0; i < int(indexChunk.Header.AddressCount); i++ { - obj := index.AddressRecord{} + obj := types.SimpleAddrRecord{} if err := binary.Read(indexChunk.File, binary.LittleEndian, &obj); err != nil { return err } diff --git a/src/apps/chifra/internal/chunks/handle_diff.go b/src/apps/chifra/internal/chunks/handle_diff.go index 9c6dfafa00..12054fb92f 100644 --- a/src/apps/chifra/internal/chunks/handle_diff.go +++ b/src/apps/chifra/internal/chunks/handle_diff.go @@ -109,27 +109,10 @@ func (opts *ChunksOptions) exportTo(dest, source string, rd base.RangeDiff) (boo if err := binary.Read(indexChunk.File, binary.LittleEndian, &s.AddressRecord); err != nil { return false, err } - var discApps []index.AppearanceRecord - discAddr := index.AddressRecord{ - Address: s.AddressRecord.Address, - Offset: s.AddressRecord.Offset, - Count: s.AddressRecord.Count, - } - if discApps, err = indexChunk.ReadAppearancesAndReset(&discAddr); err != nil { + if s.Appearances, err = indexChunk.ReadAppearancesAndReset(&s.AddressRecord); err != nil { return false, err } - s.Appearances = []types.SimpleAppRecord{} - for _, a := range discApps { - s.Appearances = append(s.Appearances, types.SimpleAppRecord{ - BlockNumber: uint32(a.BlockNumber), - TransactionIndex: uint32(a.TransactionIndex), - }) - } - s.AddressRecord = types.SimpleAddrRecord{ - Address: discAddr.Address, - Offset: discAddr.Offset, - Count: uint32(len(discApps)), - } + s.AddressRecord.Count = uint32(len(s.Appearances)) for _, app := range s.Appearances { apps = append(apps, types.SimpleAppearance{ Address: s.AddressRecord.Address, diff --git a/src/apps/chifra/pkg/index/appearance_result.go b/src/apps/chifra/pkg/index/appearance_result.go index 9c863ffab2..d84c54c586 100644 --- a/src/apps/chifra/pkg/index/appearance_result.go +++ b/src/apps/chifra/pkg/index/appearance_result.go @@ -5,6 +5,7 @@ import ( "io" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // AppearanceResult carries the appearances found in a single Index for the given address. @@ -31,7 +32,7 @@ func (chunk *Index) ReadAppearances(address base.Address) *AppearanceResult { return &ret } - addressRecord := AddressRecord{} + addressRecord := types.SimpleAddrRecord{} if err := binary.Read(chunk.File, binary.LittleEndian, &addressRecord); err != nil { ret.Err = err return &ret @@ -43,6 +44,14 @@ func (chunk *Index) ReadAppearances(address base.Address) *AppearanceResult { return &ret } - ret.AppRecords = &appearances + a := make([]AppearanceRecord, 0, len(appearances)) + for _, aa := range appearances { + a = append(a, AppearanceRecord{ + BlockNumber: aa.BlockNumber, + TransactionIndex: aa.TransactionIndex, + }) + } + ret.AppRecords = &a + return &ret } diff --git a/src/apps/chifra/pkg/index/chunk_write.go b/src/apps/chifra/pkg/index/chunk_write.go index 87113349cc..5b42247e09 100644 --- a/src/apps/chifra/pkg/index/chunk_write.go +++ b/src/apps/chifra/pkg/index/chunk_write.go @@ -13,6 +13,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/config" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) type writeReport struct { @@ -37,7 +38,7 @@ func (chunk *Chunk) Write(chain string, publisher base.Address, fileName string, // through the map // Create space for the two tables... - addressTable := make([]AddressRecord, 0, len(addrAppearanceMap)) + addressTable := make([]types.SimpleAddrRecord, 0, len(addrAppearanceMap)) appearanceTable := make([]AppearanceRecord, 0, nApps) // We want to sort the items in the map by address (maps in GoLang are not sorted) @@ -64,7 +65,7 @@ func (chunk *Chunk) Write(chain string, publisher base.Address, fileName string, bl.InsertAddress(address) // ...and append the record to the addressTable. - addressTable = append(addressTable, AddressRecord{ + addressTable = append(addressTable, types.SimpleAddrRecord{ Address: address, Offset: offset, Count: uint32(len(apps)), diff --git a/src/apps/chifra/pkg/index/index_address_record.go b/src/apps/chifra/pkg/index/index_address_record.go index b110c7a6ed..1e416ec033 100644 --- a/src/apps/chifra/pkg/index/index_address_record.go +++ b/src/apps/chifra/pkg/index/index_address_record.go @@ -8,6 +8,7 @@ import ( "sort" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) const ( @@ -15,13 +16,6 @@ const ( AddrRecordWidth = 28 ) -// AddressRecord is a single record in the Address table -type AddressRecord struct { - Address base.Address `json:"address"` - Offset uint32 `json:"offset"` - Count uint32 `json:"count"` -} - func (chunk *Index) searchForAddressRecord(address base.Address) int { compareFunc := func(pos int) bool { if pos == -1 { @@ -39,7 +33,7 @@ func (chunk *Index) searchForAddressRecord(address base.Address) int { return false } - addressRec := AddressRecord{} + addressRec := types.SimpleAddrRecord{} if err = binary.Read(chunk.File, binary.LittleEndian, &addressRec); err != nil { fmt.Println(err) return false @@ -52,7 +46,7 @@ func (chunk *Index) searchForAddressRecord(address base.Address) int { readLocation := int64(HeaderWidth + pos*AddrRecordWidth) _, _ = chunk.File.Seek(readLocation, io.SeekStart) - rec := AddressRecord{} + rec := types.SimpleAddrRecord{} if err := binary.Read(chunk.File, binary.LittleEndian, &rec); err != nil { return -1 } diff --git a/src/apps/chifra/pkg/index/index_appearance_record.go b/src/apps/chifra/pkg/index/index_appearance_record.go index c4b1d4023b..18c02f35b5 100644 --- a/src/apps/chifra/pkg/index/index_appearance_record.go +++ b/src/apps/chifra/pkg/index/index_appearance_record.go @@ -3,6 +3,8 @@ package index import ( "encoding/binary" "io" + + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) const ( @@ -16,7 +18,7 @@ type AppearanceRecord struct { TransactionIndex uint32 `json:"transactionIndex"` } -func (chunk *Index) ReadAppearancesAndReset(addrRecord *AddressRecord) (apps []AppearanceRecord, err error) { +func (chunk *Index) ReadAppearancesAndReset(addrRecord *types.SimpleAddrRecord) (apps []types.SimpleAppRecord, err error) { offset, err := chunk.File.Seek(0, io.SeekCurrent) if err != nil { return apps, err @@ -35,7 +37,7 @@ func (chunk *Index) ReadAppearancesAndReset(addrRecord *AddressRecord) (apps []A return apps, nil } -func (chunk *Index) readAppearanceRecords(addrRecord *AddressRecord) (apps []AppearanceRecord, err error) { +func (chunk *Index) readAppearanceRecords(addrRecord *types.SimpleAddrRecord) (apps []types.SimpleAppRecord, err error) { readLocation := int64(HeaderWidth + AddrRecordWidth*chunk.Header.AddressCount + AppRecordWidth*addrRecord.Offset) _, err = chunk.File.Seek(readLocation, io.SeekStart) @@ -43,7 +45,7 @@ func (chunk *Index) readAppearanceRecords(addrRecord *AddressRecord) (apps []App return } - apps = make([]AppearanceRecord, addrRecord.Count) + apps = make([]types.SimpleAppRecord, addrRecord.Count) err = binary.Read(chunk.File, binary.LittleEndian, &apps) return From 6b9b15f33e65ef8201e6eec977e99f5e759657a6 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 20:25:31 -0400 Subject: [PATCH 13/18] Removes index.AppearanceRecord in favor of types.SimpleAppRecord --- .../chifra/internal/chunks/handle_appearances.go | 2 +- .../chifra/internal/scrape/scrape_consolidate.go | 8 ++++---- src/apps/chifra/internal/scrape/scrape_prepare.go | 5 +++-- src/apps/chifra/pkg/filter/filter.go | 5 ++--- src/apps/chifra/pkg/filter/sort.go | 4 ++-- src/apps/chifra/pkg/index/appearance_result.go | 12 ++---------- src/apps/chifra/pkg/index/chunk_write.go | 4 ++-- src/apps/chifra/pkg/index/index_appearance_record.go | 6 ------ src/apps/chifra/pkg/monitor/filter.go | 4 ++-- src/apps/chifra/pkg/monitor/monitor.go | 2 +- src/apps/chifra/pkg/monitor/monitor_freshen.go | 7 ++++--- src/apps/chifra/pkg/monitor/monitor_read.go | 3 ++- src/apps/chifra/pkg/monitor/monitor_remove_dups.go | 8 ++++---- src/apps/chifra/pkg/monitor/monitor_test.go | 11 +++++------ src/apps/chifra/pkg/monitor/monitor_write.go | 5 +++-- src/apps/chifra/pkg/monitor/truncate.go | 6 +++--- 16 files changed, 40 insertions(+), 52 deletions(-) diff --git a/src/apps/chifra/internal/chunks/handle_appearances.go b/src/apps/chifra/internal/chunks/handle_appearances.go index 71f3f533e9..2230998fdf 100644 --- a/src/apps/chifra/internal/chunks/handle_appearances.go +++ b/src/apps/chifra/internal/chunks/handle_appearances.go @@ -48,7 +48,7 @@ func (opts *ChunksOptions) HandleAppearances(blockNums []uint64) error { if opts.Globals.TestMode && i > walker.MaxTests() { continue } - rec := index.AppearanceRecord{} + rec := types.SimpleAppRecord{} if err := binary.Read(indexChunk.File, binary.LittleEndian, &rec); err != nil { return false, err } diff --git a/src/apps/chifra/internal/scrape/scrape_consolidate.go b/src/apps/chifra/internal/scrape/scrape_consolidate.go index 1ff608b5b8..0f3a1e0826 100644 --- a/src/apps/chifra/internal/scrape/scrape_consolidate.go +++ b/src/apps/chifra/internal/scrape/scrape_consolidate.go @@ -124,7 +124,7 @@ func (bm *BlazeManager) Consolidate(blocks []base.Blknum) (error, bool) { // reset for next chunk bm.meta, _ = bm.opts.Conn.GetMetaData(bm.IsTestMode()) - appMap = make(map[string][]index.AppearanceRecord, 0) + appMap = make(map[string][]types.SimpleAppRecord, 0) chunkRange.First = chunkRange.Last + 1 chunkRange.Last = chunkRange.Last + 1 nAppearances = 0 @@ -175,11 +175,11 @@ func (bm *BlazeManager) Consolidate(blocks []base.Blknum) (error, bool) { } // AsciiFileToAppearanceMap reads the appearances from the stage file and returns them as a map -func (bm *BlazeManager) AsciiFileToAppearanceMap(fn string) (map[string][]index.AppearanceRecord, base.FileRange, int) { +func (bm *BlazeManager) AsciiFileToAppearanceMap(fn string) (map[string][]types.SimpleAppRecord, base.FileRange, int) { appearances := file.AsciiFileToLines(fn) os.Remove(fn) // It's okay to remove this. If it fails, we'll just start over. - appMap := make(map[string][]index.AppearanceRecord, len(appearances)) + appMap := make(map[string][]types.SimpleAppRecord, len(appearances)) fileRange := base.FileRange{First: utils.NOPOS, Last: 0} if len(appearances) == 0 { @@ -199,7 +199,7 @@ func (bm *BlazeManager) AsciiFileToAppearanceMap(fn string) (map[string][]index. } fileRange.First = utils.Min(fileRange.First, bn) fileRange.Last = utils.Max(fileRange.Last, bn) - appMap[addr] = append(appMap[addr], index.AppearanceRecord{ + appMap[addr] = append(appMap[addr], types.SimpleAppRecord{ BlockNumber: uint32(bn), TransactionIndex: uint32(txid), }) diff --git a/src/apps/chifra/internal/scrape/scrape_prepare.go b/src/apps/chifra/internal/scrape/scrape_prepare.go index 471c9631b5..c063fe365a 100644 --- a/src/apps/chifra/internal/scrape/scrape_prepare.go +++ b/src/apps/chifra/internal/scrape/scrape_prepare.go @@ -13,6 +13,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/prefunds" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/tslib" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // Prepare performs actions that need to be done prior to entering the @@ -45,10 +46,10 @@ func (opts *ScrapeOptions) Prepare() (ok bool, err error) { return false, err } - appMap := make(map[string][]index.AppearanceRecord, len(prefunds)) + appMap := make(map[string][]types.SimpleAppRecord, len(prefunds)) for i, prefund := range prefunds { addr := prefund.Address.Hex() - appMap[addr] = append(appMap[addr], index.AppearanceRecord{ + appMap[addr] = append(appMap[addr], types.SimpleAppRecord{ BlockNumber: 0, TransactionIndex: uint32(i), }) diff --git a/src/apps/chifra/pkg/filter/filter.go b/src/apps/chifra/pkg/filter/filter.go index 63a779001f..e79a0434c1 100644 --- a/src/apps/chifra/pkg/filter/filter.go +++ b/src/apps/chifra/pkg/filter/filter.go @@ -8,7 +8,6 @@ import ( "strings" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) @@ -69,7 +68,7 @@ func (f *AppearanceFilter) GetOuterBounds() base.BlockRange { } // ApplyFilter checks to see if the appearance intersects with the user-supplied --first_block/--last_block pair (if any) -func (f *AppearanceFilter) ApplyFilter(app *index.AppearanceRecord) (passed, finished bool) { +func (f *AppearanceFilter) ApplyFilter(app *types.SimpleAppRecord) (passed, finished bool) { appRange := base.FileRange{First: uint64(app.BlockNumber), Last: uint64(app.BlockNumber)} // --first_block/--last_block if !appRange.Intersects(base.FileRange(f.exportRange)) { return false, false @@ -78,7 +77,7 @@ func (f *AppearanceFilter) ApplyFilter(app *index.AppearanceRecord) (passed, fin } // ApplyRangeFilter checks to see if the appearance intersects with the user-supplied --first_block/--last_block pair (if any) -func (f *AppearanceFilter) ApplyRangeFilter(app *index.AppearanceRecord) (passed, finished bool) { +func (f *AppearanceFilter) ApplyRangeFilter(app *types.SimpleAppRecord) (passed, finished bool) { appRange := base.FileRange{First: uint64(app.BlockNumber), Last: uint64(app.BlockNumber)} // --first_block/--last_block return appRange.Intersects(base.FileRange(f.exportRange)), false } diff --git a/src/apps/chifra/pkg/filter/sort.go b/src/apps/chifra/pkg/filter/sort.go index 9813b8dcf7..88acb7fb90 100644 --- a/src/apps/chifra/pkg/filter/sort.go +++ b/src/apps/chifra/pkg/filter/sort.go @@ -3,7 +3,7 @@ package filter import ( "sort" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) type AppearanceSort int @@ -14,7 +14,7 @@ const ( Reversed ) -func (f *AppearanceFilter) Sort(fromDisc []index.AppearanceRecord) { +func (f *AppearanceFilter) Sort(fromDisc []types.SimpleAppRecord) { if f.sortBy == Sorted || f.sortBy == Reversed { sort.Slice(fromDisc, func(i, j int) bool { if f.sortBy == Reversed { diff --git a/src/apps/chifra/pkg/index/appearance_result.go b/src/apps/chifra/pkg/index/appearance_result.go index d84c54c586..bef21dd865 100644 --- a/src/apps/chifra/pkg/index/appearance_result.go +++ b/src/apps/chifra/pkg/index/appearance_result.go @@ -12,7 +12,7 @@ import ( type AppearanceResult struct { Address base.Address Range base.FileRange - AppRecords *[]AppearanceRecord + AppRecords *[]types.SimpleAppRecord Err error } @@ -44,14 +44,6 @@ func (chunk *Index) ReadAppearances(address base.Address) *AppearanceResult { return &ret } - a := make([]AppearanceRecord, 0, len(appearances)) - for _, aa := range appearances { - a = append(a, AppearanceRecord{ - BlockNumber: aa.BlockNumber, - TransactionIndex: aa.TransactionIndex, - }) - } - ret.AppRecords = &a - + ret.AppRecords = &appearances return &ret } diff --git a/src/apps/chifra/pkg/index/chunk_write.go b/src/apps/chifra/pkg/index/chunk_write.go index 5b42247e09..ed115269b6 100644 --- a/src/apps/chifra/pkg/index/chunk_write.go +++ b/src/apps/chifra/pkg/index/chunk_write.go @@ -33,13 +33,13 @@ func (c *writeReport) Report() { logger.Info(colors.ColoredWith(fmt.Sprintf(report, c.nAddresses, c.nAppearances, c.Range, c.FileSize, c.Range.Span()), colors.BrightBlue)) } -func (chunk *Chunk) Write(chain string, publisher base.Address, fileName string, addrAppearanceMap map[string][]AppearanceRecord, nApps int) (*writeReport, error) { +func (chunk *Chunk) Write(chain string, publisher base.Address, fileName string, addrAppearanceMap map[string][]types.SimpleAppRecord, nApps int) (*writeReport, error) { // We're going to build two tables. An addressTable and an appearanceTable. We do this as we spin // through the map // Create space for the two tables... addressTable := make([]types.SimpleAddrRecord, 0, len(addrAppearanceMap)) - appearanceTable := make([]AppearanceRecord, 0, nApps) + appearanceTable := make([]types.SimpleAppRecord, 0, nApps) // We want to sort the items in the map by address (maps in GoLang are not sorted) sorted := []string{} diff --git a/src/apps/chifra/pkg/index/index_appearance_record.go b/src/apps/chifra/pkg/index/index_appearance_record.go index 18c02f35b5..be89fa736a 100644 --- a/src/apps/chifra/pkg/index/index_appearance_record.go +++ b/src/apps/chifra/pkg/index/index_appearance_record.go @@ -12,12 +12,6 @@ const ( AppRecordWidth = 8 ) -// AppearanceRecord is a single record in the Appearance table -type AppearanceRecord struct { - BlockNumber uint32 `json:"blockNumber"` - TransactionIndex uint32 `json:"transactionIndex"` -} - func (chunk *Index) ReadAppearancesAndReset(addrRecord *types.SimpleAddrRecord) (apps []types.SimpleAppRecord, err error) { offset, err := chunk.File.Seek(0, io.SeekCurrent) if err != nil { diff --git a/src/apps/chifra/pkg/monitor/filter.go b/src/apps/chifra/pkg/monitor/filter.go index a532f9c3c3..d0420588c2 100644 --- a/src/apps/chifra/pkg/monitor/filter.go +++ b/src/apps/chifra/pkg/monitor/filter.go @@ -13,7 +13,7 @@ import ( ) func (mon *Monitor) ReadAndFilterAppearances(filt *filter.AppearanceFilter, withCount bool) (apps []types.SimpleAppearance, cnt int, err error) { - readAppearances := func(apps *[]index.AppearanceRecord) (err error) { + readAppearances := func(apps *[]types.SimpleAppRecord) (err error) { if int64(len(*apps)) > mon.Count() { err = fmt.Errorf("array is larger than the size of the file (%d,%d)", len(*apps), mon.Count()) return @@ -48,7 +48,7 @@ func (mon *Monitor) ReadAndFilterAppearances(filt *filter.AppearanceFilter, with return nil, 0, nil } - fromDisc := make([]index.AppearanceRecord, mon.Count()) + fromDisc := make([]types.SimpleAppRecord, mon.Count()) if err := readAppearances(&fromDisc); err != nil { mon.Close() return nil, 0, err diff --git a/src/apps/chifra/pkg/monitor/monitor.go b/src/apps/chifra/pkg/monitor/monitor.go index 180228eac5..093097d71f 100644 --- a/src/apps/chifra/pkg/monitor/monitor.go +++ b/src/apps/chifra/pkg/monitor/monitor.go @@ -22,7 +22,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) -// Header is the header of the Monitor file. Note that it's the same width as an index.AppearanceRecord +// Header is the header of the Monitor file. Note that it's the same width as an types.SimpleAppRecord // therefor one should not change its size type Header struct { Magic uint16 `json:"-"` diff --git a/src/apps/chifra/pkg/monitor/monitor_freshen.go b/src/apps/chifra/pkg/monitor/monitor_freshen.go index da03a6c88e..e9a6ec01bb 100644 --- a/src/apps/chifra/pkg/monitor/monitor_freshen.go +++ b/src/apps/chifra/pkg/monitor/monitor_freshen.go @@ -23,6 +23,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/manifest" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/sigintTrap" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/validate" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/walk" @@ -377,13 +378,13 @@ const ( endOfTxId = 42 + 1 + 9 + 1 + 5 ) -func getAppearances(addrStr string, lines []string, lastVisited uint32, found int) *[]index.AppearanceRecord { - results := make([]index.AppearanceRecord, 0, 1000) +func getAppearances(addrStr string, lines []string, lastVisited uint32, found int) *[]types.SimpleAppRecord { + results := make([]types.SimpleAppRecord, 0, 1000) for idx := found; idx < len(lines); idx++ { if !strings.HasPrefix(lines[idx], addrStr) { break } - r := index.AppearanceRecord{ + r := types.SimpleAppRecord{ BlockNumber: uint32(globals.ToUint64(lines[idx][startOfBlockNum:endOfBlockNum])), TransactionIndex: uint32(globals.ToUint64(lines[idx][startOfTxId:endOfTxId])), } diff --git a/src/apps/chifra/pkg/monitor/monitor_read.go b/src/apps/chifra/pkg/monitor/monitor_read.go index 0a06bbb29d..05dfb1e9d1 100644 --- a/src/apps/chifra/pkg/monitor/monitor_read.go +++ b/src/apps/chifra/pkg/monitor/monitor_read.go @@ -12,6 +12,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // ReadMonitorHeader reads the monitor's header and returns without closing the file @@ -31,7 +32,7 @@ func (mon *Monitor) ReadMonitorHeader() (err error) { } // ReadAppearanceAt returns the appearance at the one-based index. The file remains open. -func (mon *Monitor) ReadAppearanceAt(idx int64, app *index.AppearanceRecord) (err error) { +func (mon *Monitor) ReadAppearanceAt(idx int64, app *types.SimpleAppRecord) (err error) { if idx == 0 || idx > mon.Count() { // the file contains a header one record wide, so a one-based index eases caller code err = fmt.Errorf("index out of range in ReadAppearanceAt[%d]", idx) diff --git a/src/apps/chifra/pkg/monitor/monitor_remove_dups.go b/src/apps/chifra/pkg/monitor/monitor_remove_dups.go index 741a9943e0..a243f8c794 100644 --- a/src/apps/chifra/pkg/monitor/monitor_remove_dups.go +++ b/src/apps/chifra/pkg/monitor/monitor_remove_dups.go @@ -6,7 +6,7 @@ package monitor import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/filter" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) func (mon *Monitor) RemoveDups() (int64, int64, error) { @@ -25,10 +25,10 @@ func (mon *Monitor) RemoveDups() (int64, int64, error) { cntBefore := mon.Count() cntAfter := cntBefore - var prev index.AppearanceRecord - deDupped := make([]index.AppearanceRecord, 0, mon.Count()) + var prev types.SimpleAppRecord + deDupped := make([]types.SimpleAppRecord, 0, mon.Count()) for i, app := range apps { - iApp := index.AppearanceRecord{ + iApp := types.SimpleAppRecord{ BlockNumber: app.BlockNumber, TransactionIndex: app.TransactionIndex, } diff --git a/src/apps/chifra/pkg/monitor/monitor_test.go b/src/apps/chifra/pkg/monitor/monitor_test.go index 9c9a8646c4..7f158de7cd 100644 --- a/src/apps/chifra/pkg/monitor/monitor_test.go +++ b/src/apps/chifra/pkg/monitor/monitor_test.go @@ -12,7 +12,6 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/file" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/filter" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) @@ -51,25 +50,25 @@ func Test_Monitor_ReadApp(t *testing.T) { RemoveTestMonitor(&mon, t) }() - var got index.AppearanceRecord + var got types.SimpleAppRecord err := mon.ReadAppearanceAt(0, &got) if err == nil { t.Error("Should have been 'index out of range in ReadAppearanceAt[0]' error") } - expected := index.AppearanceRecord{BlockNumber: 1001001, TransactionIndex: 0} + expected := types.SimpleAppRecord{BlockNumber: 1001001, TransactionIndex: 0} err = mon.ReadAppearanceAt(1, &got) if got != expected || err != nil { t.Error("Expected:", expected, "Got:", got, err) } - expected = index.AppearanceRecord{BlockNumber: 1001002, TransactionIndex: 1} + expected = types.SimpleAppRecord{BlockNumber: 1001002, TransactionIndex: 1} err = mon.ReadAppearanceAt(2, &got) if got != expected || err != nil { t.Error("Expected:", expected, "Got:", got, err) } - expected = index.AppearanceRecord{BlockNumber: 1001003, TransactionIndex: 2} + expected = types.SimpleAppRecord{BlockNumber: 1001003, TransactionIndex: 2} err = mon.ReadAppearanceAt(mon.Count(), &got) if got != expected || err != nil { t.Error("Expected:", expected, "Got:", got, err) @@ -229,7 +228,7 @@ func RemoveTestMonitor(mon *Monitor, t *testing.T) { const nTests = 3 -var testApps = []index.AppearanceRecord{ +var testApps = []types.SimpleAppRecord{ {BlockNumber: 1001001, TransactionIndex: 0}, {BlockNumber: 1001002, TransactionIndex: 1}, {BlockNumber: 1001003, TransactionIndex: 2}, diff --git a/src/apps/chifra/pkg/monitor/monitor_write.go b/src/apps/chifra/pkg/monitor/monitor_write.go index 438995310f..a99e1740c1 100644 --- a/src/apps/chifra/pkg/monitor/monitor_write.go +++ b/src/apps/chifra/pkg/monitor/monitor_write.go @@ -11,6 +11,7 @@ import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/logger" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" ) // TODO: Protect against overwriting files on disc @@ -36,7 +37,7 @@ func (mon *Monitor) WriteMonHeader(deleted bool, lastScanned uint32, force bool) // WriteAppearancesAppend appends appearances to the end of the file, updates the header with // lastScanned (if later) and returns the number of records written. Note that we should // be writing to a temporary file. -func (mon *Monitor) WriteAppearancesAppend(lastScanned uint32, apps *[]index.AppearanceRecord) error { +func (mon *Monitor) WriteAppearancesAppend(lastScanned uint32, apps *[]types.SimpleAppRecord) error { if !mon.Staged { logger.Fatal("should not happen ==> trying to write to a non-staged file") @@ -64,7 +65,7 @@ func (mon *Monitor) WriteAppearancesAppend(lastScanned uint32, apps *[]index.App // TODO: Protect against overwriting files on disc // WriteAppearances writes appearances to a Monitor -func (mon *Monitor) WriteAppearances(apps []index.AppearanceRecord, append bool) (int64, error) { +func (mon *Monitor) WriteAppearances(apps []types.SimpleAppRecord, append bool) (int64, error) { var f *os.File var err error path := mon.Path() diff --git a/src/apps/chifra/pkg/monitor/truncate.go b/src/apps/chifra/pkg/monitor/truncate.go index 552b606914..bc6a539007 100644 --- a/src/apps/chifra/pkg/monitor/truncate.go +++ b/src/apps/chifra/pkg/monitor/truncate.go @@ -2,7 +2,7 @@ package monitor import ( "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/filter" - "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/index" + "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/utils" ) @@ -19,10 +19,10 @@ func (mon *Monitor) TruncateTo(chain string, num uint32) (bool, error) { return false, nil } else { - var keep []index.AppearanceRecord + var keep []types.SimpleAppRecord for _, app := range apps { if app.BlockNumber <= num { - keep = append(keep, index.AppearanceRecord{ + keep = append(keep, types.SimpleAppRecord{ BlockNumber: app.BlockNumber, TransactionIndex: app.TransactionIndex, }) From 92ac0fbce5719deff40e9da909c0d746335d0723 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 20:59:32 -0400 Subject: [PATCH 14/18] Cleaning --- docs/content/api/openapi.yaml | 2 +- docs/content/data-model/accounts.md | 8 ++++---- src/apps/chifra/pkg/types/types_appearanceTable.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/content/api/openapi.yaml b/docs/content/api/openapi.yaml index 7c7a9078fe..0b54276e9c 100644 --- a/docs/content/api/openapi.yaml +++ b/docs/content/api/openapi.yaml @@ -3022,7 +3022,7 @@ components: $ref: "#/components/schemas/addrRecord" description: "the address record for these appearances" Appearances: - type: object + type: array items: $ref: "#/components/schemas/appRecord" description: "all the appearances for this address" diff --git a/docs/content/data-model/accounts.md b/docs/content/data-model/accounts.md index ef213977bc..f86eab1edf 100644 --- a/docs/content/data-model/accounts.md +++ b/docs/content/data-model/accounts.md @@ -68,10 +68,10 @@ The following commands produce and manage AppearanceTables: AppearanceTables consist of the following fields: -| Field | Description | Type | -| ------------- | ---------------------------------------- | ---------- | -| AddressRecord | the address record for these appearances | AddrRecord | -| Appearances | all the appearances for this address | AppRecord | +| Field | Description | Type | +| ------------- | ---------------------------------------- | ----------- | +| AddressRecord | the address record for these appearances | AddrRecord | +| Appearances | all the appearances for this address | AppRecord[] | ## Monitor diff --git a/src/apps/chifra/pkg/types/types_appearanceTable.go b/src/apps/chifra/pkg/types/types_appearanceTable.go index b0a7a0a442..62754fb9b3 100644 --- a/src/apps/chifra/pkg/types/types_appearanceTable.go +++ b/src/apps/chifra/pkg/types/types_appearanceTable.go @@ -29,15 +29,15 @@ type SimpleAppRecord struct { // EXISTING_CODE type RawAppearanceTable struct { - AddressRecord string `json:"AddressRecord"` - Appearances string `json:"Appearances"` + AddressRecord string `json:"AddressRecord"` + Appearances []string `json:"Appearances"` // EXISTING_CODE // EXISTING_CODE } type SimpleAppearanceTable struct { - AddressRecord SimpleAddrRecord `json:"addressRecord"` - Appearances []SimpleAppRecord `json:"appearances"` + AddressRecord SimpleAddrRecord `json:"AddressRecord"` + Appearances []SimpleAppRecord `json:"Appearances"` raw *RawAppearanceTable `json:"-"` // EXISTING_CODE // EXISTING_CODE From 4ad3681b092ab79cecf03a75f4efdeab10eceec9 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 21:15:20 -0400 Subject: [PATCH 15/18] Removes the idea of goOutput folder for auto-gen --- src/dev_tools/goMaker/main.go | 1 - .../templates/classDefinitions/abi.toml | 1 - .../classDefinitions/appearance.toml | 1 - .../classDefinitions/appearancecount.toml | 1 - .../classDefinitions/appearancetable.toml | 1 - .../templates/classDefinitions/block.toml | 1 - .../classDefinitions/blockcount.toml | 1 - .../templates/classDefinitions/bounds.toml | 1 - .../templates/classDefinitions/cacheitem.toml | 1 - .../templates/classDefinitions/chain.toml | 1 - .../classDefinitions/chunkaddress.toml | 1 - .../classDefinitions/chunkbloom.toml | 1 - .../classDefinitions/chunkindex.toml | 1 - .../classDefinitions/chunkpinreport.toml | 1 - .../classDefinitions/chunkrecord.toml | 1 - .../classDefinitions/chunkstats.toml | 1 - .../templates/classDefinitions/function.toml | 1 - .../templates/classDefinitions/ipfspin.toml | 1 - .../templates/classDefinitions/log.toml | 1 - .../templates/classDefinitions/logfilter.toml | 1 - .../templates/classDefinitions/manifest.toml | 1 - .../templates/classDefinitions/monitor.toml | 1 - .../classDefinitions/monitorclean.toml | 1 - .../templates/classDefinitions/name.toml | 1 - .../classDefinitions/namedblock.toml | 1 - .../templates/classDefinitions/parameter.toml | 1 - .../templates/classDefinitions/receipt.toml | 1 - .../classDefinitions/reportcheck.toml | 1 - .../templates/classDefinitions/result.toml | 1 - .../templates/classDefinitions/slurp.toml | 1 - .../templates/classDefinitions/state.toml | 1 - .../templates/classDefinitions/statement.toml | 1 - .../templates/classDefinitions/status.toml | 1 - .../templates/classDefinitions/timestamp.toml | 1 - .../classDefinitions/timestampcount.toml | 1 - .../templates/classDefinitions/token.toml | 1 - .../templates/classDefinitions/trace.toml | 1 - .../classDefinitions/traceaction.toml | 1 - .../classDefinitions/tracecount.toml | 1 - .../classDefinitions/tracefilter.toml | 1 - .../classDefinitions/traceresult.toml | 1 - .../classDefinitions/transaction.toml | 1 - .../classDefinitions/withdrawal.toml | 1 - ...s_chifra_internal_route_types_type.go.tmpl | 50 ------------------- src/dev_tools/goMaker/types/load.go | 4 -- .../goMaker/types/process_structure.go | 28 +---------- .../goMaker/types/types_structure.go | 1 - 47 files changed, 2 insertions(+), 124 deletions(-) delete mode 100644 src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl diff --git a/src/dev_tools/goMaker/main.go b/src/dev_tools/goMaker/main.go index 6c84b676fe..44cf9a7da6 100644 --- a/src/dev_tools/goMaker/main.go +++ b/src/dev_tools/goMaker/main.go @@ -49,7 +49,6 @@ var cbTemplates = []types.Generator{ Templates: []string{ "src_dev+tools_goMaker_generated_model+type.md.tmpl", "src_apps_chifra_pkg_types_type.go.tmpl", - "src_apps_chifra_internal_route_types_type.go.tmpl", }, }, { diff --git a/src/dev_tools/goMaker/templates/classDefinitions/abi.toml b/src/dev_tools/goMaker/templates/classDefinitions/abi.toml index 62e304ba0a..8fba0c3af5 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/abi.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/abi.toml @@ -4,4 +4,3 @@ doc_descr = "a human-readable representation of a Solidity smart contract" doc_route = "503-abi" produced_by = "abis" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/appearance.toml b/src/dev_tools/goMaker/templates/classDefinitions/appearance.toml index 0101be3bd5..eae54beed0 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/appearance.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/appearance.toml @@ -5,4 +5,3 @@ doc_descr = "an appearance (``) of an address anywhere on the chain (note that in some cases, not all fields will appear depending on the command)" doc_route = "103-appearance" produced_by = "list, export, blocks, chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/appearancecount.toml b/src/dev_tools/goMaker/templates/classDefinitions/appearancecount.toml index 4254426284..b20ddbb89b 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/appearancecount.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/appearancecount.toml @@ -4,4 +4,3 @@ doc_descr = "the number of records, file size, and last visited block for a given monitor" doc_route = "112-appearanceCount" produced_by = "list, export" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml b/src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml index 349828439f..674fa9873d 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/appearancetable.toml @@ -5,4 +5,3 @@ doc_descr = "an appearance table for an address" doc_route = "103-appearanceTable" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/block.toml b/src/dev_tools/goMaker/templates/classDefinitions/block.toml index 4aa96b9b5c..0194dba127 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/block.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/block.toml @@ -4,7 +4,6 @@ doc_descr = "block data as returned from the RPC (with slight enhancements)" doc_route = "203-block" produced_by = "blocks, when" - go_output = "src/apps/chifra/pkg/types" go_model = "Block[Tx]" cache_type = "cacheable" cache_by = "block" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml b/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml index 110e5a18be..d0f26e9b37 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/blockcount.toml @@ -4,4 +4,3 @@ doc_descr = "counts of various parts of the block data such as tx_count, trace_count, etc." doc_route = "236-blockCount" produced_by = "blocks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/bounds.toml b/src/dev_tools/goMaker/templates/classDefinitions/bounds.toml index 9d394e404f..7cfcc38e41 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/bounds.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/bounds.toml @@ -4,4 +4,3 @@ doc_descr = "show first block and last block an address appears in along with timestamps and dates" doc_route = "115-bounds" produced_by = "list" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml b/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml index a39d21a724..8b23c21492 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/cacheitem.toml @@ -5,4 +5,3 @@ doc_descr = "a single entry in the results of a status query when `--verbose` is enabled" doc_route = "430-cacheItem" produced_by = "status" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chain.toml b/src/dev_tools/goMaker/templates/classDefinitions/chain.toml index 92664f405e..a45a6cf52b 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chain.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chain.toml @@ -5,4 +5,3 @@ doc_descr = "a configuration item carrying information about a single chain" doc_route = "439-chain" produced_by = "status, config" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml index ce94cc428e..be9d943f6c 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkaddress.toml @@ -4,4 +4,3 @@ doc_descr = "internal-use only data model detailing a single address record in the address table of an index chunk" doc_route = "418-chunkAddress" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml index e9b7541b6d..3c7bd13fd2 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkbloom.toml @@ -4,4 +4,3 @@ doc_descr = "internal-use only data model detailing a single bloom filter file" doc_route = "415-chunkBloom" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml index 75e256372a..7d297955db 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkindex.toml @@ -4,4 +4,3 @@ doc_descr = "internal-use only data model detailing a single index chunk file" doc_route = "412-chunkIndex" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml index eeb7b63f21..19d4eace58 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkpinreport.toml @@ -4,4 +4,3 @@ doc_descr = "a JSON object containing the results of pinning the Unchained Index" doc_route = "436-chunkPinReport" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkrecord.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkrecord.toml index 25d17906d5..f866816647 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkrecord.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkrecord.toml @@ -5,4 +5,3 @@ doc_descr = "a single record in the manifest detailing the IPFS hases and file sizes for each bloom filter and index chunk" doc_route = "409-chunkRecord" produced_by = "chunks, init, scrape" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/chunkstats.toml b/src/dev_tools/goMaker/templates/classDefinitions/chunkstats.toml index 6522641f04..007f98c867 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/chunkstats.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/chunkstats.toml @@ -4,4 +4,3 @@ doc_descr = "summary statistics about an Unchained Index bloom filter and index chunk" doc_route = "424-chunkStats" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/function.toml b/src/dev_tools/goMaker/templates/classDefinitions/function.toml index c2d1ae81a7..2ca89eb2ed 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/function.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/function.toml @@ -5,5 +5,4 @@ doc_descr = "a human-readable representation of a Solidity function call or event" doc_route = "506-function" produced_by = "abis, export" - go_output = "src/apps/chifra/pkg/types" cache_type = "marshal_only" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml b/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml index 993b8835e2..16f3fd751e 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/ipfspin.toml @@ -4,4 +4,3 @@ doc_descr = "internal-use only data model detailing a single remote or local ipfs pinned file" doc_route = "421-ipfsPin" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/log.toml b/src/dev_tools/goMaker/templates/classDefinitions/log.toml index 292bc431ae..f49e8bd9dc 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/log.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/log.toml @@ -5,7 +5,6 @@ doc_descr = "log data as returned from the RPC (with slight enhancements)" doc_route = "215-log" produced_by = "logs, export, blocks" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "block" cache_as = "group" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/logfilter.toml b/src/dev_tools/goMaker/templates/classDefinitions/logfilter.toml index 7484d594a0..da42a7fa7d 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/logfilter.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/logfilter.toml @@ -4,4 +4,3 @@ doc_descr = "used by the fast path log queries for various commands" doc_route = "218-logFilter" produced_by = "blocks, logs" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/manifest.toml b/src/dev_tools/goMaker/templates/classDefinitions/manifest.toml index f58afa9956..b3d7bd3656 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/manifest.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/manifest.toml @@ -4,4 +4,3 @@ doc_descr = "a JSON object containing records for each bloom filter and index chunk in the Unchained Index" doc_route = "406-manifest" produced_by = "chunks, init, scrape" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/monitor.toml b/src/dev_tools/goMaker/templates/classDefinitions/monitor.toml index 67e619145e..58373d5066 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/monitor.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/monitor.toml @@ -5,4 +5,3 @@ doc_descr = "a local file indicating a user's interest in an address. Includes caches for reconicilations, transactions, and appearances as well as an optional association to named account" doc_route = "106-monitor" produced_by = "monitors, list, export" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml b/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml index c027cc9edf..14711e474d 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/monitorclean.toml @@ -4,4 +4,3 @@ doc_descr = "report on cleaning dups out of monitors" doc_route = "427-monitorClean" produced_by = "monitors" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/name.toml b/src/dev_tools/goMaker/templates/classDefinitions/name.toml index 5749f1a021..a760733c04 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/name.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/name.toml @@ -4,4 +4,3 @@ doc_descr = "an association between a human-readable name and an address used throughout TrueBlocks" doc_route = "109-name" produced_by = "names" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/namedblock.toml b/src/dev_tools/goMaker/templates/classDefinitions/namedblock.toml index d3beb722b2..37754b1831 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/namedblock.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/namedblock.toml @@ -4,4 +4,3 @@ doc_descr = "a block that has been given a particular name such as `first` or `latest`" doc_route = "239-namedBlock" produced_by = "when" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/parameter.toml b/src/dev_tools/goMaker/templates/classDefinitions/parameter.toml index 9252bfcc18..0cc3616073 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/parameter.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/parameter.toml @@ -5,5 +5,4 @@ doc_descr = "an input or output parameter to a Solidity function or event" doc_route = "509-parameter" produced_by = "abis, export" - go_output = "src/apps/chifra/pkg/types" cache_type = "marshal_only" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/receipt.toml b/src/dev_tools/goMaker/templates/classDefinitions/receipt.toml index edd9e0ab51..0d24b4e1d5 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/receipt.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/receipt.toml @@ -5,7 +5,6 @@ doc_descr = "receipt data as returned from the RPC (with slight enhancements)" doc_route = "212-receipt" produced_by = "receipts, export" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "block" cache_as = "group" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml b/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml index c48879590b..f16725e4c8 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/reportcheck.toml @@ -4,4 +4,3 @@ doc_descr = "report on checking contents of chunks" doc_route = "433-reportCheck" produced_by = "chunks" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/result.toml b/src/dev_tools/goMaker/templates/classDefinitions/result.toml index cfe62252ac..1d6339a37e 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/result.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/result.toml @@ -4,6 +4,5 @@ doc_descr = "the result (articulated if possible, as bytes otherwise) of a call to a smart contract" doc_route = "309-result" produced_by = "state" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "address,block,fourbyte" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/slurp.toml b/src/dev_tools/goMaker/templates/classDefinitions/slurp.toml index ee05c00495..27e678d958 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/slurp.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/slurp.toml @@ -4,7 +4,6 @@ doc_descr = "transaction data as returned from by Etherscan" doc_route = "512-slurp" produced_by = "slurp" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "address,tx" cache_as = "group" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/state.toml b/src/dev_tools/goMaker/templates/classDefinitions/state.toml index 5b13d1fac2..f6f03df528 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/state.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/state.toml @@ -4,6 +4,5 @@ doc_descr = "the state of an Ethereum account (EOA or smart contract) on-chain" doc_route = "303-state" produced_by = "state" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "address,block" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/statement.toml b/src/dev_tools/goMaker/templates/classDefinitions/statement.toml index cbbb71ad47..1b64b03c85 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/statement.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/statement.toml @@ -5,7 +5,6 @@ doc_descr = "a statement, including all inflows and outflows, for a single transfer of an asset (including ETH) to or from a given address" doc_route = "118-statement" produced_by = "export" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "address,tx" cache_as = "group" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/status.toml b/src/dev_tools/goMaker/templates/classDefinitions/status.toml index a8e77323ce..70c0a08f3d 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/status.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/status.toml @@ -4,4 +4,3 @@ doc_descr = "status-related data about the TrueBlocks system including the server and local binary caches" doc_route = "403-status" produced_by = "status" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml b/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml index c61a77b9d8..bb0e9ec849 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/timestamp.toml @@ -4,4 +4,3 @@ doc_descr = "the timestamp, date and difference in timestamp of previous block produced by chifra when" doc_route = "242-timestamp" produced_by = "when" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml b/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml index 754465b1ae..d4e70e3123 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/timestampcount.toml @@ -4,4 +4,3 @@ doc_descr = "the number of timestamps in the timestamps database" doc_route = "245-timestampCount" produced_by = "when" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/token.toml b/src/dev_tools/goMaker/templates/classDefinitions/token.toml index 5c8a99c845..cb13b2ce4c 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/token.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/token.toml @@ -4,4 +4,3 @@ doc_descr = "on-chain token-related data such as totalSupply, symbol, decimals, and individual balances for a given address at a given block" doc_route = "306-token" produced_by = "tokens, export" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/trace.toml b/src/dev_tools/goMaker/templates/classDefinitions/trace.toml index 8f97d6d699..ba8688c83f 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/trace.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/trace.toml @@ -5,7 +5,6 @@ doc_descr = "trace data as returned from the RPC (with slight enhancements)" doc_route = "221-trace" produced_by = "traces, export, blocks" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "tx" cache_as = "group" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/traceaction.toml b/src/dev_tools/goMaker/templates/classDefinitions/traceaction.toml index 86337489aa..0bea5539d4 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/traceaction.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/traceaction.toml @@ -5,5 +5,4 @@ doc_descr = "trace action data as returned from the RPC (with slight enhancements)" doc_route = "224-traceAction" produced_by = "traces, export, blocks" - go_output = "src/apps/chifra/pkg/types" cache_type = "marshal_only" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml b/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml index 9ad359d8a0..269365581c 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/tracecount.toml @@ -4,4 +4,3 @@ doc_descr = "counts the number of traces in a transaction" doc_route = "230-traceCount" produced_by = "traces" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/tracefilter.toml b/src/dev_tools/goMaker/templates/classDefinitions/tracefilter.toml index aff8b983e3..8fd7c7fda9 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/tracefilter.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/tracefilter.toml @@ -4,4 +4,3 @@ doc_descr = "used by chifra traces --filter option to query for traces" doc_route = "233-traceFilter" produced_by = "traces" - go_output = "src/apps/chifra/pkg/types" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/traceresult.toml b/src/dev_tools/goMaker/templates/classDefinitions/traceresult.toml index 2dbe56cd66..cb383db691 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/traceresult.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/traceresult.toml @@ -5,5 +5,4 @@ doc_descr = "trace result data as returned from the RPC (with slight enhancements)" doc_route = "227-traceResult" produced_by = "traces, export, blocks" - go_output = "src/apps/chifra/pkg/types" cache_type = "marshal_only" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/transaction.toml b/src/dev_tools/goMaker/templates/classDefinitions/transaction.toml index b83435272c..0fc27c41e4 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/transaction.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/transaction.toml @@ -5,6 +5,5 @@ doc_descr = "transaction data as returned from the RPC (with slight enhancements)" doc_route = "206-transaction" produced_by = "transactions, export" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "tx" diff --git a/src/dev_tools/goMaker/templates/classDefinitions/withdrawal.toml b/src/dev_tools/goMaker/templates/classDefinitions/withdrawal.toml index ef0637e5ba..1a71f85ad9 100644 --- a/src/dev_tools/goMaker/templates/classDefinitions/withdrawal.toml +++ b/src/dev_tools/goMaker/templates/classDefinitions/withdrawal.toml @@ -5,7 +5,6 @@ doc_descr = "withdrawal record for post-Shanghai withdrawals from the consensus layer" doc_route = "209-withdrawal" produced_by = "blocks" - go_output = "src/apps/chifra/pkg/types" cache_type = "cacheable" cache_by = "block" cache_as = "group" diff --git a/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl b/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl deleted file mode 100644 index 24898f24e0..0000000000 --- a/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_types_type.go.tmpl +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. -// Use of this source code is governed by a license that can -// be found in the LICENSE file. -/* - * Parts of this file were auto generated. Edit only those parts of - * the code inside of 'EXISTING_CODE' tags. - */ - -package {{.Route}}Pkg - -// EXISTING_CODE -// EXISTING_CODE - -type simple{{.Class}} struct { -{{range .Members}}{{if .IsSimpField}}{{.GoName}} {{.GoType}} {{.Tag}} -{{end}}{{end}} - // EXISTING_CODE - // EXISTING_CODE -} - -func (s *simple{{.Class}}) String() string { - bytes, _ := json.Marshal(s) - return string(bytes) -} - -func (s *simple{{.Class}}) Raw() *types.RawModeler { - return nil -} - -func (s *simple{{.Class}}) Model(chain, format string, verbose bool, extraOptions map[string]any) types.Model { - var model = map[string]interface{}{} - var order = []string{} - - // EXISTING_CODE - // EXISTING_CODE - - return types.Model{ - Data: model, - Order: order, - } -} - -{{if .HasTimestamp}} -func (s *simple{{.ModelName}}) Date() string { - return utils.FormattedDate(s.Timestamp) -} -{{end}} - -// EXISTING_CODE -// EXISTING_CODE diff --git a/src/dev_tools/goMaker/types/load.go b/src/dev_tools/goMaker/types/load.go index f7fdc77d6b..f4acbe5548 100644 --- a/src/dev_tools/goMaker/types/load.go +++ b/src/dev_tools/goMaker/types/load.go @@ -96,10 +96,6 @@ func (cb *CodeBase) LoadStructures(thePath string, structMap map[string]Structur if f.Settings.Class[0] == 'C' { f.Settings.Class = f.Settings.Class[1:] } - if f.Settings.GoOutput == "documentation only" { - f.Settings.GoOutput = "" - f.Settings.DisableGo = true - } mapKey := strings.ToLower(class) structMap[mapKey] = f.Settings } diff --git a/src/dev_tools/goMaker/types/process_structure.go b/src/dev_tools/goMaker/types/process_structure.go index b1a0d5b612..d3b97c35c0 100644 --- a/src/dev_tools/goMaker/types/process_structure.go +++ b/src/dev_tools/goMaker/types/process_structure.go @@ -22,37 +22,13 @@ func (s *Structure) ProcessFile(source string) error { return nil } - dest := "" - isSourceInternal := strings.Contains(source, "internal") - isSourceGenerated := strings.Contains(source, "generated") - isDestInternal := strings.Contains(s.GoOutput, "internal") - - if !isSourceGenerated && (isDestInternal && !isSourceInternal || isSourceInternal && !isDestInternal) { - // fmt.Println("Mismatch", s.Class) - return nil - } else if isDestInternal { - s.Route = grabRoute(s.GoOutput) - dest = convertToDestPath(source, s.Route, s.Name(), "") - dest = strings.Replace(dest, "/types/", "/types_", -1) - // return nil - } else { - dest = convertToDestPath(source, "", s.Name(), "") - } - + dest := convertToDestPath(source, "", s.Name(), "") tmpl := file.AsciiFileToString(source) result := s.executeTemplate(source, tmpl) - dest = strings.Replace(dest, "/src/apps/chifra/pkg/types/", "/"+s.GoOutput+"/types_", -1) + dest = strings.Replace(dest, "/src/apps/chifra/pkg/types/", "/src/apps/chifra/pkg/types/types_", -1) return codeWriter.WriteCode(dest, result) } -func grabRoute(dest string) string { - if !strings.Contains(dest, "/internal/") { - return "" - } - parts := strings.Split(dest, "/") - return parts[len(parts)-1] -} - func readStructure(st *Structure, data *any) (bool, error) { st.DocDescr = strings.ReplaceAll(st.DocDescr, ",", ",") return true, nil diff --git a/src/dev_tools/goMaker/types/types_structure.go b/src/dev_tools/goMaker/types/types_structure.go index a38b080cb3..5f49a4467d 100644 --- a/src/dev_tools/goMaker/types/types_structure.go +++ b/src/dev_tools/goMaker/types/types_structure.go @@ -13,7 +13,6 @@ import ( type Structure struct { Class string `json:"class,omitempty" toml:"class" csv:"class"` BaseClass string `json:"base_class,omitempty" toml:"base_class"` - GoOutput string `json:"go_output,omitempty" toml:"go_output"` DocGroup string `json:"doc_group,omitempty" toml:"doc_group" csv:"doc_group"` DocRoute string `json:"doc_route,omitempty" toml:"doc_route"` DocDescr string `json:"doc_descr,omitempty" toml:"doc_descr" csv:"doc_descr"` From 1b95049f7380ae27f2b06b68f0066ef39f86ee57 Mon Sep 17 00:00:00 2001 From: Gary Snipes <77077163+G-Snipes@users.noreply.github.com> Date: Tue, 9 Apr 2024 21:33:01 -0400 Subject: [PATCH 16/18] Fix Typos in Comments (#3569) * modified readme.md in bin * cacheing to caching example fix * test commit again * Fix typos * Fix typos * Fix typos --------- Co-authored-by: Gary Snipes --- CHANGES.md | 8 ++++---- CONTRIBUTING.md | 2 +- README.md | 2 +- docs/content/api/openapi.yaml | 2 +- src/apps/chifra/internal/abis/doc.go | 2 +- src/apps/chifra/internal/abis/output.go | 2 +- src/apps/chifra/internal/blocks/doc.go | 2 +- src/apps/chifra/internal/chunks/doc.go | 2 +- src/apps/chifra/internal/config/doc.go | 2 +- src/apps/chifra/internal/daemon/doc.go | 2 +- src/apps/chifra/internal/explore/doc.go | 2 +- src/apps/chifra/internal/export/doc.go | 2 +- src/apps/chifra/internal/init/doc.go | 2 +- src/apps/chifra/internal/list/doc.go | 2 +- src/apps/chifra/pkg/rpc/get_block.go | 2 +- src/apps/chifra/pkg/tslib/tsdb.go | 2 +- src/apps/chifra/pkg/uniq/uniq_appearances.go | 2 +- src/apps/chifra/pkg/usage/usage.go | 2 +- src/dev_tools/utillib/basenode.cpp | 6 +++--- src/dev_tools/utillib/json_token.cpp | 2 +- src/dev_tools/utillib/json_value.cpp | 2 +- src/dev_tools/utillib/options_base.cpp | 6 +++--- src/dev_tools/utillib/sfos.cpp | 2 +- src/dev_tools/utillib/toml.cpp | 2 +- src/examples/README.md | 2 +- 25 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b9aa98a51d..6c1950e870 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1604,7 +1604,7 @@ There were no changes to the [Specification for the Unchained Index](https://tru - We completed partial ports for `chifra blocks`, `chifra transactions`, and `chifra traces`. In some cases, this changed the format of the output (especially for JSON output). In every case, we think the data has been improved. - Implemented `--articulate` across many tools in GoLang. (Thanks Dawid!) - We made significant improvements to the documentation including more examples for the API docs and cross links to data models from tools producing the same. -- We prepared all tools for using the GoLang `--cache` options (caching is not yet yet enabled in the GoLang code). (Thanks Dawid!) +- We prepared all tools for using the GoLang `--cache` options (caching is not yet enabled in the GoLang code). (Thanks Dawid!) - Better support for streaming output to various formats (including preliminary support for `.xlsx`). - Begun improvements for more useful and flexible connections to the RPC. @@ -1614,7 +1614,7 @@ There were no changes to the [Specification for the Unchained Index](https://tru - Changed `abi_source` to `abiSource`. - Changed `input_dicts` to `inputDicts`. - Changed `output_dicts` to `outputDicts`. - - Removed `input_names` and `output_names`. (These may be added back in in the future.) + - Removed `input_names` and `output_names`. (These may be added back in the future.) - `Reconciliation` data model: - Changed `prevBlock` to `prevAppBlk`. - Changed `prevBlkBal` to `prevBal`. @@ -1747,7 +1747,7 @@ There were no changes to the [Specification for the Unchained Index](https://tru - Removed `--tsx` option as unused. - Removed `--dump` option as unused. - Added `--sdk` option to output Python and Typescript SDKs. -- Separation of `CParameter` class from `CMember` class making publically presented `CParamater` much simple since most of the complications came from that class's use in makeClass. +- Separation of `CParameter` class from `CMember` class making publically presented `CParamater` much simpler since most of the complications came from that class's use in makeClass. **testRunner** @@ -1793,7 +1793,7 @@ With this release, we made a lot of improvements to the help file and the code. **chifra traces** -- An attempt was made to improve the data exported from this tool, as it was quite confused previously. There may be unforeseen breaking changes to the expotred data. +- An attempt was made to improve the data exported from this tool, as it was quite confused previously. There may be unforeseen breaking changes to the exported data. - Removed unused (and previously unimplemented) `--statediff` option. - Partial port to GoLang. See note above. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b499ee40d5..3940e5ab9c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ ## Did you make a formatting or cosmetic change? -- We use an automated formatters, therefor formatting-only changes will generally be closed without merging. +- We use an automated formatters, therefore formatting-only changes will generally be closed without merging. ## Would do have a feature request? diff --git a/README.md b/README.md index acb073fd6b..deaffb09b7 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Let's look at the first subcommand, called `status`. chifra status ``` -If you get a bunch of data, congratulations, your installation is working. Try this command which shows every 10th block between the first and the 100,000th: +If you get a bunch of data, congratulations, your installation is working. Try this command which shows every 10th block between the first and the 100,000th: ```[shell] chifra blocks 0-100000:10 diff --git a/docs/content/api/openapi.yaml b/docs/content/api/openapi.yaml index c62a438b37..b331c0f0eb 100644 --- a/docs/content/api/openapi.yaml +++ b/docs/content/api/openapi.yaml @@ -58,7 +58,7 @@ info: "http://localhost:8080/blocks?blocks=100-110&cache=true" ``` - Cacheing speeds up repeat queries significantly. The cache options are + Caching speeds up repeat queries significantly. The cache options are particularly useful for calls to data-rich endpoints, like most endpoints in the "Accounts" collection. diff --git a/src/apps/chifra/internal/abis/doc.go b/src/apps/chifra/internal/abis/doc.go index 4a38fe63c7..e63d897739 100644 --- a/src/apps/chifra/internal/abis/doc.go +++ b/src/apps/chifra/internal/abis/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package abisPkg handles the chifra abis command. It The tool retrieves one or more ABI files for the given address(es). It searches for ABIs, sequentially, in the following locations: - the current working folder, - the TrueBlocks local cache, - Etherscan, - (in the future) ENS and Sourcify. While this tool may be used from the command line, its primary purpose is in support of the --articulate option for tools such as chifra export and chifra logs. If possible, the tool will follow proxied addresses searching for the ABI, but that does not always work. In that case, you may use the --proxy_for option. The --known option prints a list of semi-standard function signatures such as the ERC20 standard, ERC 721 standard, various functions from OpenZeppelin, various Uniswap functions, etc. As an optimization, the known signatures are searched first during articulation. The --encode option generates a 32-byte encoding for a given cannonical function or event signature. For functions, you may manually extract the first four bytes of the hash. The --find option is experimental. Please see the notes below for more information. +// Package abisPkg handles the chifra abis command. The tool retrieves one or more ABI files for the given address(es). It searches for ABIs, sequentially, in the following locations: - the current working folder, - the TrueBlocks local cache, - Etherscan, - (in the future) ENS and Sourcify. While this tool may be used from the command line, its primary purpose is in support of the --articulate option for tools such as chifra export and chifra logs. If possible, the tool will follow proxied addresses searching for the ABI, but that does not always work. In that case, you may use the --proxy_for option. The --known option prints a list of semi-standard function signatures such as the ERC20 standard, ERC 721 standard, various functions from OpenZeppelin, various Uniswap functions, etc. As an optimization, the known signatures are searched first during articulation. The --encode option generates a 32-byte encoding for a given cannonical function or event signature. For functions, you may manually extract the first four bytes of the hash. The --find option is experimental. Please see the notes below for more information. package abisPkg diff --git a/src/apps/chifra/internal/abis/output.go b/src/apps/chifra/internal/abis/output.go index 97c149fc76..270b226295 100644 --- a/src/apps/chifra/internal/abis/output.go +++ b/src/apps/chifra/internal/abis/output.go @@ -42,7 +42,7 @@ func ServeAbis(w http.ResponseWriter, r *http.Request) error { return err } -// AbisInternal handles the internal workings of the abis command. Returns an error. +// AbisInternal handles the internal workings of the abis command. Returns an error. func (opts *AbisOptions) AbisInternal() error { var err error if err = opts.validateAbis(); err != nil { diff --git a/src/apps/chifra/internal/blocks/doc.go b/src/apps/chifra/internal/blocks/doc.go index 2846cf701b..1b282615d8 100644 --- a/src/apps/chifra/internal/blocks/doc.go +++ b/src/apps/chifra/internal/blocks/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package blocksPkg handles the chifra blocks command. It The tool retrieves block data from your Ethereum node or, if previously cached, from the TrueBlocks cache. You may specify multiple blocks per invocation. By default, queries the full transactional details of the block (including receipts). You may optionally retrieve only the transaction hashes in the block (which is significantly faster). Additionally, you may also use this tool to retrieve uncle blocks at a give height. Another useful feature of is the ability to extract address appearances from a block. TrueBlocks uses a similar feature internally to build its index of appearances. This type of data is very insightful when studying end user behavior and chain-wide adoption analysis. +// Package blocksPkg handles the chifra blocks command. It retrieves block data from your Ethereum node or, if previously cached, from the TrueBlocks cache. You may specify multiple blocks per invocation. By default, queries the full transactional details of the block (including receipts). You may optionally retrieve only the transaction hashes in the block (which is significantly faster). Additionally, you may also use this tool to retrieve uncle blocks at a give height. Another useful feature of is the ability to extract address appearances from a block. TrueBlocks uses a similar feature internally to build its index of appearances. This type of data is very insightful when studying end user behavior and chain-wide adoption analysis. package blocksPkg diff --git a/src/apps/chifra/internal/chunks/doc.go b/src/apps/chifra/internal/chunks/doc.go index 14cb5c0765..afb8222e94 100644 --- a/src/apps/chifra/internal/chunks/doc.go +++ b/src/apps/chifra/internal/chunks/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package chunksPkg handles the chifra chunks command. It The 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. +// Package chunksPkg handles the chifra chunks command. It 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. package chunksPkg diff --git a/src/apps/chifra/internal/config/doc.go b/src/apps/chifra/internal/config/doc.go index 798471927d..4759f44212 100644 --- a/src/apps/chifra/internal/config/doc.go +++ b/src/apps/chifra/internal/config/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package configPkg handles the chifra config command. It The program allows you to manage the various TrueBlocks caches. You may list all of the caches, some of the cache, or even individual caches either in terse or full detail. The cache of interest is specified with the modes option. TrueBlocks maintains caches for the index of address appearances, named addresses, abi files, as well as other data including blockchain data, and address monitors. +// Package configPkg handles the chifra config command. It allows you to manage the various TrueBlocks caches. You may list all of the caches, some of the cache, or even individual caches either in terse or full detail. The cache of interest is specified with the modes option. TrueBlocks maintains caches for the index of address appearances, named addresses, abi files, as well as other data including blockchain data, and address monitors. package configPkg diff --git a/src/apps/chifra/internal/daemon/doc.go b/src/apps/chifra/internal/daemon/doc.go index 0c839a4d81..a29dd3b966 100644 --- a/src/apps/chifra/internal/daemon/doc.go +++ b/src/apps/chifra/internal/daemon/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package daemonPkg handles the chifra daemon command. It manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the command. In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server. The --grpc option turns on a GRPC server that may speed up certain command such as chifra names, although this option is experimental and therefore not recommended for production use. If the default port for the API server is in use, you may change it with the --port option. To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra --help on your command line to get help. See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options. +// Package daemonPkg handles the chifra daemon command. It manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the command. In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server. The --grpc option turns on a GRPC server that may speed up certain command such as chifra names, although this option is experimental and therefore not recommended for production use. If the default port for the API server is in use, you may change it with the --port option. To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra --help on your command line to get help. See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options. package daemonPkg diff --git a/src/apps/chifra/internal/explore/doc.go b/src/apps/chifra/internal/explore/doc.go index 4bf0052221..acc5a16492 100644 --- a/src/apps/chifra/internal/explore/doc.go +++ b/src/apps/chifra/internal/explore/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package explorePkg handles the chifra explore command. It opens Etherscan (and other explorers -- including our own) to the block identifier, transaction identifier, or address you specify. It's a handy (configurable) way to open an explorer from the command line, nothing more. +// Package explorePkg handles the chifra explore command. It opens Etherscan (and other explorers -- including our own) to the block identifier, transaction identifier, or address you specify. It's a handy (configurable) way to open an explorer from the command line, nothing more. package explorePkg diff --git a/src/apps/chifra/internal/export/doc.go b/src/apps/chifra/internal/export/doc.go index 1114140980..e02f1241cc 100644 --- a/src/apps/chifra/internal/export/doc.go +++ b/src/apps/chifra/internal/export/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package exportPkg handles the chifra export command. It The tools provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, completes the actual extraction of an address's transactional history from the node. You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results. You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish. By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you. +// Package exportPkg handles the chifra export command. It provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, completes the actual extraction of an address's transactional history from the node. You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results. You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish. By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you. package exportPkg diff --git a/src/apps/chifra/internal/init/doc.go b/src/apps/chifra/internal/init/doc.go index af2f098835..3cfe047a78 100644 --- a/src/apps/chifra/internal/init/doc.go +++ b/src/apps/chifra/internal/init/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// 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. +// Package initPkg handles the chifra init command. When invoked it 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. package initPkg diff --git a/src/apps/chifra/internal/list/doc.go b/src/apps/chifra/internal/list/doc.go index 56adb654ab..31fdfe048a 100644 --- a/src/apps/chifra/internal/list/doc.go +++ b/src/apps/chifra/internal/list/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package listPkg handles the chifra list command. It takes one or more addresses, queries the index of appearances, and builds TrueBlocks monitors. A TrueBlocks monitor is a file that contains blockNumber.transactionIndex pairs (transaction identifiers) representing the history of the address. Because TrueBlocks only extracts data from the Ethereum node when it's requested, the first time you list an address it takes about a minute. Subsequent queries are much faster because TrueBlocks caches the results. Note that chifra list only queries the index, it does not extract the full transactional details. You may use chifra export for that. +// Package listPkg handles the chifra list command. It takes one or more addresses, queries the index of appearances, and builds TrueBlocks monitors. A TrueBlocks monitor is a file that contains blockNumber.transactionIndex pairs (transaction identifiers) representing the history of the address. Because TrueBlocks only extracts data from the Ethereum node when it's requested, the first time you list an address it takes about a minute. Subsequent queries are much faster because TrueBlocks caches the results. Note that chifra list only queries the index, it does not extract the full transactional details. You may use chifra export for that. package listPkg diff --git a/src/apps/chifra/pkg/rpc/get_block.go b/src/apps/chifra/pkg/rpc/get_block.go index adf1cc6ab2..ea629c98e4 100644 --- a/src/apps/chifra/pkg/rpc/get_block.go +++ b/src/apps/chifra/pkg/rpc/get_block.go @@ -235,7 +235,7 @@ func loadBlock[Tx string | types.SimpleTransaction](conn *Connection, bn uint64, block = types.SimpleBlock[Tx]{ BlockNumber: blockNumber, - Timestamp: base.Timestamp(ts), // note that we turn Ethereum's timestamps into types.Timestamp upon read. + Timestamp: base.Timestamp(ts), // note that we turn Ethereum's timestamps into types. Timestamp upon read. Hash: base.HexToHash(rawBlock.Hash), ParentHash: base.HexToHash(rawBlock.ParentHash), GasLimit: gasLimit, diff --git a/src/apps/chifra/pkg/tslib/tsdb.go b/src/apps/chifra/pkg/tslib/tsdb.go index c3c548ccb0..3393335a15 100644 --- a/src/apps/chifra/pkg/tslib/tsdb.go +++ b/src/apps/chifra/pkg/tslib/tsdb.go @@ -130,7 +130,7 @@ func ClearCache(chain string) { } // FromBn is a local function that returns a Timestamp record given a blockNum. It -// loads the timestamp file into memory if it isn't already +// loads the timestamp file into memory if it isn't already loaded func FromBn(chain string, bn uint64) (*TimestampRecord, error) { cnt, err := NTimestamps(chain) if err != nil { diff --git a/src/apps/chifra/pkg/uniq/uniq_appearances.go b/src/apps/chifra/pkg/uniq/uniq_appearances.go index 8aa33a3d15..9e4b832b4e 100644 --- a/src/apps/chifra/pkg/uniq/uniq_appearances.go +++ b/src/apps/chifra/pkg/uniq/uniq_appearances.go @@ -182,7 +182,7 @@ func UniqFromTraces(chain string, traces []types.SimpleTrace, addrMap AddressBoo var mapSync sync.Mutex -// addAddressToMaps help keep track of appearances for an address. An appearance is inserted into `appsMap` +// addAddressToMaps helps keep track of appearances for an address. An appearance is inserted into `appsMap` // if we've never seen this appearance before. `appsMap` is used to build the appearance table when writing the // chunk. `addrMap` helps eliminate duplicates and is used to build the address table when writing the chunk. // Precompiles are ignored. If the given address string does not start with a lead `0x`, it is normalized. diff --git a/src/apps/chifra/pkg/usage/usage.go b/src/apps/chifra/pkg/usage/usage.go index f43fd80736..facc15180a 100644 --- a/src/apps/chifra/pkg/usage/usage.go +++ b/src/apps/chifra/pkg/usage/usage.go @@ -6,7 +6,7 @@ import ( "strings" ) -// Replace accepts an string and an arbitrary number of additional string parameters. It replaces +// Replace accepts a string and an arbitrary number of additional string parameters. It replaces // {N} in the string with the Nth additional string. func Replace(msg string, values ...string) string { ret := msg diff --git a/src/dev_tools/utillib/basenode.cpp b/src/dev_tools/utillib/basenode.cpp index 7c8fa9c194..85b88e3d08 100644 --- a/src/dev_tools/utillib/basenode.cpp +++ b/src/dev_tools/utillib/basenode.cpp @@ -28,7 +28,7 @@ namespace qblocks { //-------------------------------------------------------------------------------- CRuntimeClass CBaseNode::classCBaseNode; static CBuiltIn _biBaseNode(&CBaseNode::classCBaseNode, "CBaseNode", sizeof(CBaseNode), NULL, NULL); -vector builtIns; // Keeps track of all the classes that have beebn registered +vector builtIns; // Keeps track of all the classes that have been registered //-------------------------------------------------------------------------------- CBaseNode::CBaseNode(void) { @@ -669,7 +669,7 @@ string_q nextBasenodeChunk(const string_q& fieldIn, const CBaseNode* node) { string_q getNextChunk(string_q& fmtOut, NEXTCHUNKFUNC func, const void* data) { string_q chunk = fmtOut; if (!contains(fmtOut, "[")) { - // There are no more tokens. Return the last chunk and empty out the format + // There are no more tokens. Return the last chunk and empty out the format fmtOut = ""; return chunk; } @@ -684,7 +684,7 @@ string_q getNextChunk(string_q& fmtOut, NEXTCHUNKFUNC func, const void* data) { } // We've hit a token, toss the start token, look for a field and toss the last token - // leaving the remainder of the format in fmtOut. A field is found if we find a pair + // leaving the remainder of the format in fmtOut. A field is found if we find a pair // of squigglies). Save text inside the start token and outside the field in pre and post ASSERT(startsWith(fmtOut, '[')); diff --git a/src/dev_tools/utillib/json_token.cpp b/src/dev_tools/utillib/json_token.cpp index 27551f0374..a4ae3820be 100644 --- a/src/dev_tools/utillib/json_token.cpp +++ b/src/dev_tools/utillib/json_token.cpp @@ -210,7 +210,7 @@ bool decodeNumber_4(Token& token, Value& decoded) { const auto digit(static_cast(c - '0')); if (value >= threshold) { // We've hit or exceeded the max value divided by 10 (rounded down). If - // a) we've only just touched the limit, meaing value == threshold, + // a) we've only just touched the limit, meaning value == threshold, // b) this is the last digit, or // c) it's small enough to fit in that rounding delta, we're okay. // Otherwise treat this number as a double to avoid overflow. diff --git a/src/dev_tools/utillib/json_value.cpp b/src/dev_tools/utillib/json_value.cpp index 04ae0027eb..9bac997712 100644 --- a/src/dev_tools/utillib/json_value.cpp +++ b/src/dev_tools/utillib/json_value.cpp @@ -136,7 +136,7 @@ ValueIteratorBase::computeDistance(const SelfType& other) const { // RogueWave STL, // which is the one used by default). // Using a portable hand-made version for non random iterator instead: - // return difference_type( std::distance( current_, other.current_ ) ); + // return difference_type( std::distance( current_, other.current_ ) ); difference_type myDistance = 0; for (std::map::iterator it = current_; it != other.current_; ++it) { ++myDistance; diff --git a/src/dev_tools/utillib/options_base.cpp b/src/dev_tools/utillib/options_base.cpp index c4e9ffd9d1..797abf0637 100644 --- a/src/dev_tools/utillib/options_base.cpp +++ b/src/dev_tools/utillib/options_base.cpp @@ -224,7 +224,7 @@ bool COptionsBase::prepareArguments(int argCountIn, const char* argvIn[]) { if (!arg.empty()) argumentsOut3.push_back(arg); - // If we have a command file, we will use it, if not we will creat one and pretend we have one. + // If we have a command file, we will use it, if not we will create one and pretend we have one. string_q commandList = ""; for (auto arg : argumentsOut3) { commandList += (arg + " "); @@ -259,7 +259,7 @@ bool COptionsBase::standardOptions(string_q& cmdLine) { replaceAll(cmdLine, "--append", ""); } - // Note: check each item individual in case more than one appears on the command line + // Note: check each item individually in case more than one appears on the command line cmdLine += " "; replace(cmdLine, "--output ", "--output:"); @@ -402,7 +402,7 @@ void COptionsBase::configureDisplay(const string_q& tool, const string_q& dataTy case TXT1: case CSV1: if (isTestMode()) { - // Just warning the user as if this is set it may break test cases + // Just warning the user cause if this is set it may break test cases string test = getGlobalConfig(tool)->getConfigStr("display", "format", ""); if (test != "") LOG_WARN("Tests will fail. Custom display string set to: ", test); diff --git a/src/dev_tools/utillib/sfos.cpp b/src/dev_tools/utillib/sfos.cpp index 1514ba2592..15480a43a4 100644 --- a/src/dev_tools/utillib/sfos.cpp +++ b/src/dev_tools/utillib/sfos.cpp @@ -183,7 +183,7 @@ string_q doCommand(const string_q& cmd, bool readStderr) { if (system(theCommand.c_str())) {} // Don't remove cruft. Silences compiler warnings // clang-format on - // Check twice for existance since the previous command creates the file but may take some time + // Check twice for existence since the previous command creates the file but may take some time waitForCreate(filename); string_q ret; asciiFileToString(filename, ret); diff --git a/src/dev_tools/utillib/toml.cpp b/src/dev_tools/utillib/toml.cpp index 64ac233186..1cd66a6495 100644 --- a/src/dev_tools/utillib/toml.cpp +++ b/src/dev_tools/utillib/toml.cpp @@ -223,7 +223,7 @@ string_q CToml::getConfigStr(const string_q& section, const string_q& key, const //------------------------------------------------------------------------- uint64_t CToml::getVersion(void) const { - // handle older ways of stroring version. Note: after 0.6.0, always stored as [version]current + // handle older ways of storing version. Note: after 0.6.0, always stored as [version]current string_q value = getConfigStr("version", "current", getConfigStr("", "version", "0.0.0")); uint16_t v1 = (uint16_t)str_2_Uint(nextTokenClear(value, '.')); uint16_t v2 = (uint16_t)str_2_Uint(nextTokenClear(value, '.')); diff --git a/src/examples/README.md b/src/examples/README.md index e4e1a480b4..826faf342c 100644 --- a/src/examples/README.md +++ b/src/examples/README.md @@ -22,7 +22,7 @@ In the folder, `dynamic` are a few examples of building [custom traversers](http | Name | Description | | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | | [simple1](./dynamic/simple1/README.md) | A simple example of a dynamic traverser | -| [gasHole](./dynamic/gasHole/README.md) | A simple example show how to account for gas spent of sucessful and failed transactions | +| [gasHole](./dynamic/gasHole/README.md) | A simple example show how to account for gas spent of successful and failed transactions | | [balances](./dynamic/balances/README.md) | A simple example of producing a balance history for an account | | [filtering](./dynamic/filtering/README.md) | An example of filtering for particular data in an account's transaction history | | [recons](./dynamic/recons/README.md) | An example of reconciling an account's history at every transaction | From f45e0b23adc3e7b3e71c82a621c2029b69a2f1f9 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 21:35:44 -0400 Subject: [PATCH 17/18] Revert "Fix Typos in Comments (#3569)" (#3570) This reverts commit 1b95049f7380ae27f2b06b68f0066ef39f86ee57. --- CHANGES.md | 8 ++++---- CONTRIBUTING.md | 2 +- README.md | 2 +- docs/content/api/openapi.yaml | 2 +- src/apps/chifra/internal/abis/doc.go | 2 +- src/apps/chifra/internal/abis/output.go | 2 +- src/apps/chifra/internal/blocks/doc.go | 2 +- src/apps/chifra/internal/chunks/doc.go | 2 +- src/apps/chifra/internal/config/doc.go | 2 +- src/apps/chifra/internal/daemon/doc.go | 2 +- src/apps/chifra/internal/explore/doc.go | 2 +- src/apps/chifra/internal/export/doc.go | 2 +- src/apps/chifra/internal/init/doc.go | 2 +- src/apps/chifra/internal/list/doc.go | 2 +- src/apps/chifra/pkg/rpc/get_block.go | 2 +- src/apps/chifra/pkg/tslib/tsdb.go | 2 +- src/apps/chifra/pkg/uniq/uniq_appearances.go | 2 +- src/apps/chifra/pkg/usage/usage.go | 2 +- src/dev_tools/utillib/basenode.cpp | 6 +++--- src/dev_tools/utillib/json_token.cpp | 2 +- src/dev_tools/utillib/json_value.cpp | 2 +- src/dev_tools/utillib/options_base.cpp | 6 +++--- src/dev_tools/utillib/sfos.cpp | 2 +- src/dev_tools/utillib/toml.cpp | 2 +- src/examples/README.md | 2 +- 25 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6c1950e870..b9aa98a51d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1604,7 +1604,7 @@ There were no changes to the [Specification for the Unchained Index](https://tru - We completed partial ports for `chifra blocks`, `chifra transactions`, and `chifra traces`. In some cases, this changed the format of the output (especially for JSON output). In every case, we think the data has been improved. - Implemented `--articulate` across many tools in GoLang. (Thanks Dawid!) - We made significant improvements to the documentation including more examples for the API docs and cross links to data models from tools producing the same. -- We prepared all tools for using the GoLang `--cache` options (caching is not yet enabled in the GoLang code). (Thanks Dawid!) +- We prepared all tools for using the GoLang `--cache` options (caching is not yet yet enabled in the GoLang code). (Thanks Dawid!) - Better support for streaming output to various formats (including preliminary support for `.xlsx`). - Begun improvements for more useful and flexible connections to the RPC. @@ -1614,7 +1614,7 @@ There were no changes to the [Specification for the Unchained Index](https://tru - Changed `abi_source` to `abiSource`. - Changed `input_dicts` to `inputDicts`. - Changed `output_dicts` to `outputDicts`. - - Removed `input_names` and `output_names`. (These may be added back in the future.) + - Removed `input_names` and `output_names`. (These may be added back in in the future.) - `Reconciliation` data model: - Changed `prevBlock` to `prevAppBlk`. - Changed `prevBlkBal` to `prevBal`. @@ -1747,7 +1747,7 @@ There were no changes to the [Specification for the Unchained Index](https://tru - Removed `--tsx` option as unused. - Removed `--dump` option as unused. - Added `--sdk` option to output Python and Typescript SDKs. -- Separation of `CParameter` class from `CMember` class making publically presented `CParamater` much simpler since most of the complications came from that class's use in makeClass. +- Separation of `CParameter` class from `CMember` class making publically presented `CParamater` much simple since most of the complications came from that class's use in makeClass. **testRunner** @@ -1793,7 +1793,7 @@ With this release, we made a lot of improvements to the help file and the code. **chifra traces** -- An attempt was made to improve the data exported from this tool, as it was quite confused previously. There may be unforeseen breaking changes to the exported data. +- An attempt was made to improve the data exported from this tool, as it was quite confused previously. There may be unforeseen breaking changes to the expotred data. - Removed unused (and previously unimplemented) `--statediff` option. - Partial port to GoLang. See note above. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3940e5ab9c..b499ee40d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ ## Did you make a formatting or cosmetic change? -- We use an automated formatters, therefore formatting-only changes will generally be closed without merging. +- We use an automated formatters, therefor formatting-only changes will generally be closed without merging. ## Would do have a feature request? diff --git a/README.md b/README.md index deaffb09b7..acb073fd6b 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Let's look at the first subcommand, called `status`. chifra status ``` -If you get a bunch of data, congratulations, your installation is working. Try this command which shows every 10th block between the first and the 100,000th: +If you get a bunch of data, congratulations, your installation is working. Try this command which shows every 10th block between the first and the 100,000th: ```[shell] chifra blocks 0-100000:10 diff --git a/docs/content/api/openapi.yaml b/docs/content/api/openapi.yaml index b331c0f0eb..c62a438b37 100644 --- a/docs/content/api/openapi.yaml +++ b/docs/content/api/openapi.yaml @@ -58,7 +58,7 @@ info: "http://localhost:8080/blocks?blocks=100-110&cache=true" ``` - Caching speeds up repeat queries significantly. The cache options are + Cacheing speeds up repeat queries significantly. The cache options are particularly useful for calls to data-rich endpoints, like most endpoints in the "Accounts" collection. diff --git a/src/apps/chifra/internal/abis/doc.go b/src/apps/chifra/internal/abis/doc.go index e63d897739..4a38fe63c7 100644 --- a/src/apps/chifra/internal/abis/doc.go +++ b/src/apps/chifra/internal/abis/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package abisPkg handles the chifra abis command. The tool retrieves one or more ABI files for the given address(es). It searches for ABIs, sequentially, in the following locations: - the current working folder, - the TrueBlocks local cache, - Etherscan, - (in the future) ENS and Sourcify. While this tool may be used from the command line, its primary purpose is in support of the --articulate option for tools such as chifra export and chifra logs. If possible, the tool will follow proxied addresses searching for the ABI, but that does not always work. In that case, you may use the --proxy_for option. The --known option prints a list of semi-standard function signatures such as the ERC20 standard, ERC 721 standard, various functions from OpenZeppelin, various Uniswap functions, etc. As an optimization, the known signatures are searched first during articulation. The --encode option generates a 32-byte encoding for a given cannonical function or event signature. For functions, you may manually extract the first four bytes of the hash. The --find option is experimental. Please see the notes below for more information. +// Package abisPkg handles the chifra abis command. It The tool retrieves one or more ABI files for the given address(es). It searches for ABIs, sequentially, in the following locations: - the current working folder, - the TrueBlocks local cache, - Etherscan, - (in the future) ENS and Sourcify. While this tool may be used from the command line, its primary purpose is in support of the --articulate option for tools such as chifra export and chifra logs. If possible, the tool will follow proxied addresses searching for the ABI, but that does not always work. In that case, you may use the --proxy_for option. The --known option prints a list of semi-standard function signatures such as the ERC20 standard, ERC 721 standard, various functions from OpenZeppelin, various Uniswap functions, etc. As an optimization, the known signatures are searched first during articulation. The --encode option generates a 32-byte encoding for a given cannonical function or event signature. For functions, you may manually extract the first four bytes of the hash. The --find option is experimental. Please see the notes below for more information. package abisPkg diff --git a/src/apps/chifra/internal/abis/output.go b/src/apps/chifra/internal/abis/output.go index 270b226295..97c149fc76 100644 --- a/src/apps/chifra/internal/abis/output.go +++ b/src/apps/chifra/internal/abis/output.go @@ -42,7 +42,7 @@ func ServeAbis(w http.ResponseWriter, r *http.Request) error { return err } -// AbisInternal handles the internal workings of the abis command. Returns an error. +// AbisInternal handles the internal workings of the abis command. Returns an error. func (opts *AbisOptions) AbisInternal() error { var err error if err = opts.validateAbis(); err != nil { diff --git a/src/apps/chifra/internal/blocks/doc.go b/src/apps/chifra/internal/blocks/doc.go index 1b282615d8..2846cf701b 100644 --- a/src/apps/chifra/internal/blocks/doc.go +++ b/src/apps/chifra/internal/blocks/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package blocksPkg handles the chifra blocks command. It retrieves block data from your Ethereum node or, if previously cached, from the TrueBlocks cache. You may specify multiple blocks per invocation. By default, queries the full transactional details of the block (including receipts). You may optionally retrieve only the transaction hashes in the block (which is significantly faster). Additionally, you may also use this tool to retrieve uncle blocks at a give height. Another useful feature of is the ability to extract address appearances from a block. TrueBlocks uses a similar feature internally to build its index of appearances. This type of data is very insightful when studying end user behavior and chain-wide adoption analysis. +// Package blocksPkg handles the chifra blocks command. It The tool retrieves block data from your Ethereum node or, if previously cached, from the TrueBlocks cache. You may specify multiple blocks per invocation. By default, queries the full transactional details of the block (including receipts). You may optionally retrieve only the transaction hashes in the block (which is significantly faster). Additionally, you may also use this tool to retrieve uncle blocks at a give height. Another useful feature of is the ability to extract address appearances from a block. TrueBlocks uses a similar feature internally to build its index of appearances. This type of data is very insightful when studying end user behavior and chain-wide adoption analysis. package blocksPkg diff --git a/src/apps/chifra/internal/chunks/doc.go b/src/apps/chifra/internal/chunks/doc.go index afb8222e94..14cb5c0765 100644 --- a/src/apps/chifra/internal/chunks/doc.go +++ b/src/apps/chifra/internal/chunks/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package chunksPkg handles the chifra chunks command. It 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. +// Package chunksPkg handles the chifra chunks command. It The 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. package chunksPkg diff --git a/src/apps/chifra/internal/config/doc.go b/src/apps/chifra/internal/config/doc.go index 4759f44212..798471927d 100644 --- a/src/apps/chifra/internal/config/doc.go +++ b/src/apps/chifra/internal/config/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package configPkg handles the chifra config command. It allows you to manage the various TrueBlocks caches. You may list all of the caches, some of the cache, or even individual caches either in terse or full detail. The cache of interest is specified with the modes option. TrueBlocks maintains caches for the index of address appearances, named addresses, abi files, as well as other data including blockchain data, and address monitors. +// Package configPkg handles the chifra config command. It The program allows you to manage the various TrueBlocks caches. You may list all of the caches, some of the cache, or even individual caches either in terse or full detail. The cache of interest is specified with the modes option. TrueBlocks maintains caches for the index of address appearances, named addresses, abi files, as well as other data including blockchain data, and address monitors. package configPkg diff --git a/src/apps/chifra/internal/daemon/doc.go b/src/apps/chifra/internal/daemon/doc.go index a29dd3b966..0c839a4d81 100644 --- a/src/apps/chifra/internal/daemon/doc.go +++ b/src/apps/chifra/internal/daemon/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package daemonPkg handles the chifra daemon command. It manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the command. In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server. The --grpc option turns on a GRPC server that may speed up certain command such as chifra names, although this option is experimental and therefore not recommended for production use. If the default port for the API server is in use, you may change it with the --port option. To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra --help on your command line to get help. See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options. +// Package daemonPkg handles the chifra daemon command. It manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the command. In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server. The --grpc option turns on a GRPC server that may speed up certain command such as chifra names, although this option is experimental and therefore not recommended for production use. If the default port for the API server is in use, you may change it with the --port option. To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra --help on your command line to get help. See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options. package daemonPkg diff --git a/src/apps/chifra/internal/explore/doc.go b/src/apps/chifra/internal/explore/doc.go index acc5a16492..4bf0052221 100644 --- a/src/apps/chifra/internal/explore/doc.go +++ b/src/apps/chifra/internal/explore/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package explorePkg handles the chifra explore command. It opens Etherscan (and other explorers -- including our own) to the block identifier, transaction identifier, or address you specify. It's a handy (configurable) way to open an explorer from the command line, nothing more. +// Package explorePkg handles the chifra explore command. It opens Etherscan (and other explorers -- including our own) to the block identifier, transaction identifier, or address you specify. It's a handy (configurable) way to open an explorer from the command line, nothing more. package explorePkg diff --git a/src/apps/chifra/internal/export/doc.go b/src/apps/chifra/internal/export/doc.go index e02f1241cc..1114140980 100644 --- a/src/apps/chifra/internal/export/doc.go +++ b/src/apps/chifra/internal/export/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package exportPkg handles the chifra export command. It provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, completes the actual extraction of an address's transactional history from the node. You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results. You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish. By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you. +// Package exportPkg handles the chifra export command. It The tools provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, completes the actual extraction of an address's transactional history from the node. You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results. You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish. By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you. package exportPkg diff --git a/src/apps/chifra/internal/init/doc.go b/src/apps/chifra/internal/init/doc.go index 3cfe047a78..af2f098835 100644 --- a/src/apps/chifra/internal/init/doc.go +++ b/src/apps/chifra/internal/init/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package initPkg handles the chifra init command. When invoked it 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. +// 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. package initPkg diff --git a/src/apps/chifra/internal/list/doc.go b/src/apps/chifra/internal/list/doc.go index 31fdfe048a..56adb654ab 100644 --- a/src/apps/chifra/internal/list/doc.go +++ b/src/apps/chifra/internal/list/doc.go @@ -6,6 +6,6 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package listPkg handles the chifra list command. It takes one or more addresses, queries the index of appearances, and builds TrueBlocks monitors. A TrueBlocks monitor is a file that contains blockNumber.transactionIndex pairs (transaction identifiers) representing the history of the address. Because TrueBlocks only extracts data from the Ethereum node when it's requested, the first time you list an address it takes about a minute. Subsequent queries are much faster because TrueBlocks caches the results. Note that chifra list only queries the index, it does not extract the full transactional details. You may use chifra export for that. +// Package listPkg handles the chifra list command. It takes one or more addresses, queries the index of appearances, and builds TrueBlocks monitors. A TrueBlocks monitor is a file that contains blockNumber.transactionIndex pairs (transaction identifiers) representing the history of the address. Because TrueBlocks only extracts data from the Ethereum node when it's requested, the first time you list an address it takes about a minute. Subsequent queries are much faster because TrueBlocks caches the results. Note that chifra list only queries the index, it does not extract the full transactional details. You may use chifra export for that. package listPkg diff --git a/src/apps/chifra/pkg/rpc/get_block.go b/src/apps/chifra/pkg/rpc/get_block.go index ea629c98e4..adf1cc6ab2 100644 --- a/src/apps/chifra/pkg/rpc/get_block.go +++ b/src/apps/chifra/pkg/rpc/get_block.go @@ -235,7 +235,7 @@ func loadBlock[Tx string | types.SimpleTransaction](conn *Connection, bn uint64, block = types.SimpleBlock[Tx]{ BlockNumber: blockNumber, - Timestamp: base.Timestamp(ts), // note that we turn Ethereum's timestamps into types. Timestamp upon read. + Timestamp: base.Timestamp(ts), // note that we turn Ethereum's timestamps into types.Timestamp upon read. Hash: base.HexToHash(rawBlock.Hash), ParentHash: base.HexToHash(rawBlock.ParentHash), GasLimit: gasLimit, diff --git a/src/apps/chifra/pkg/tslib/tsdb.go b/src/apps/chifra/pkg/tslib/tsdb.go index 3393335a15..c3c548ccb0 100644 --- a/src/apps/chifra/pkg/tslib/tsdb.go +++ b/src/apps/chifra/pkg/tslib/tsdb.go @@ -130,7 +130,7 @@ func ClearCache(chain string) { } // FromBn is a local function that returns a Timestamp record given a blockNum. It -// loads the timestamp file into memory if it isn't already loaded +// loads the timestamp file into memory if it isn't already func FromBn(chain string, bn uint64) (*TimestampRecord, error) { cnt, err := NTimestamps(chain) if err != nil { diff --git a/src/apps/chifra/pkg/uniq/uniq_appearances.go b/src/apps/chifra/pkg/uniq/uniq_appearances.go index 9e4b832b4e..8aa33a3d15 100644 --- a/src/apps/chifra/pkg/uniq/uniq_appearances.go +++ b/src/apps/chifra/pkg/uniq/uniq_appearances.go @@ -182,7 +182,7 @@ func UniqFromTraces(chain string, traces []types.SimpleTrace, addrMap AddressBoo var mapSync sync.Mutex -// addAddressToMaps helps keep track of appearances for an address. An appearance is inserted into `appsMap` +// addAddressToMaps help keep track of appearances for an address. An appearance is inserted into `appsMap` // if we've never seen this appearance before. `appsMap` is used to build the appearance table when writing the // chunk. `addrMap` helps eliminate duplicates and is used to build the address table when writing the chunk. // Precompiles are ignored. If the given address string does not start with a lead `0x`, it is normalized. diff --git a/src/apps/chifra/pkg/usage/usage.go b/src/apps/chifra/pkg/usage/usage.go index facc15180a..f43fd80736 100644 --- a/src/apps/chifra/pkg/usage/usage.go +++ b/src/apps/chifra/pkg/usage/usage.go @@ -6,7 +6,7 @@ import ( "strings" ) -// Replace accepts a string and an arbitrary number of additional string parameters. It replaces +// Replace accepts an string and an arbitrary number of additional string parameters. It replaces // {N} in the string with the Nth additional string. func Replace(msg string, values ...string) string { ret := msg diff --git a/src/dev_tools/utillib/basenode.cpp b/src/dev_tools/utillib/basenode.cpp index 85b88e3d08..7c8fa9c194 100644 --- a/src/dev_tools/utillib/basenode.cpp +++ b/src/dev_tools/utillib/basenode.cpp @@ -28,7 +28,7 @@ namespace qblocks { //-------------------------------------------------------------------------------- CRuntimeClass CBaseNode::classCBaseNode; static CBuiltIn _biBaseNode(&CBaseNode::classCBaseNode, "CBaseNode", sizeof(CBaseNode), NULL, NULL); -vector builtIns; // Keeps track of all the classes that have been registered +vector builtIns; // Keeps track of all the classes that have beebn registered //-------------------------------------------------------------------------------- CBaseNode::CBaseNode(void) { @@ -669,7 +669,7 @@ string_q nextBasenodeChunk(const string_q& fieldIn, const CBaseNode* node) { string_q getNextChunk(string_q& fmtOut, NEXTCHUNKFUNC func, const void* data) { string_q chunk = fmtOut; if (!contains(fmtOut, "[")) { - // There are no more tokens. Return the last chunk and empty out the format + // There are no more tokens. Return the last chunk and empty out the format fmtOut = ""; return chunk; } @@ -684,7 +684,7 @@ string_q getNextChunk(string_q& fmtOut, NEXTCHUNKFUNC func, const void* data) { } // We've hit a token, toss the start token, look for a field and toss the last token - // leaving the remainder of the format in fmtOut. A field is found if we find a pair + // leaving the remainder of the format in fmtOut. A field is found if we find a pair // of squigglies). Save text inside the start token and outside the field in pre and post ASSERT(startsWith(fmtOut, '[')); diff --git a/src/dev_tools/utillib/json_token.cpp b/src/dev_tools/utillib/json_token.cpp index a4ae3820be..27551f0374 100644 --- a/src/dev_tools/utillib/json_token.cpp +++ b/src/dev_tools/utillib/json_token.cpp @@ -210,7 +210,7 @@ bool decodeNumber_4(Token& token, Value& decoded) { const auto digit(static_cast(c - '0')); if (value >= threshold) { // We've hit or exceeded the max value divided by 10 (rounded down). If - // a) we've only just touched the limit, meaning value == threshold, + // a) we've only just touched the limit, meaing value == threshold, // b) this is the last digit, or // c) it's small enough to fit in that rounding delta, we're okay. // Otherwise treat this number as a double to avoid overflow. diff --git a/src/dev_tools/utillib/json_value.cpp b/src/dev_tools/utillib/json_value.cpp index 9bac997712..04ae0027eb 100644 --- a/src/dev_tools/utillib/json_value.cpp +++ b/src/dev_tools/utillib/json_value.cpp @@ -136,7 +136,7 @@ ValueIteratorBase::computeDistance(const SelfType& other) const { // RogueWave STL, // which is the one used by default). // Using a portable hand-made version for non random iterator instead: - // return difference_type( std::distance( current_, other.current_ ) ); + // return difference_type( std::distance( current_, other.current_ ) ); difference_type myDistance = 0; for (std::map::iterator it = current_; it != other.current_; ++it) { ++myDistance; diff --git a/src/dev_tools/utillib/options_base.cpp b/src/dev_tools/utillib/options_base.cpp index 797abf0637..c4e9ffd9d1 100644 --- a/src/dev_tools/utillib/options_base.cpp +++ b/src/dev_tools/utillib/options_base.cpp @@ -224,7 +224,7 @@ bool COptionsBase::prepareArguments(int argCountIn, const char* argvIn[]) { if (!arg.empty()) argumentsOut3.push_back(arg); - // If we have a command file, we will use it, if not we will create one and pretend we have one. + // If we have a command file, we will use it, if not we will creat one and pretend we have one. string_q commandList = ""; for (auto arg : argumentsOut3) { commandList += (arg + " "); @@ -259,7 +259,7 @@ bool COptionsBase::standardOptions(string_q& cmdLine) { replaceAll(cmdLine, "--append", ""); } - // Note: check each item individually in case more than one appears on the command line + // Note: check each item individual in case more than one appears on the command line cmdLine += " "; replace(cmdLine, "--output ", "--output:"); @@ -402,7 +402,7 @@ void COptionsBase::configureDisplay(const string_q& tool, const string_q& dataTy case TXT1: case CSV1: if (isTestMode()) { - // Just warning the user cause if this is set it may break test cases + // Just warning the user as if this is set it may break test cases string test = getGlobalConfig(tool)->getConfigStr("display", "format", ""); if (test != "") LOG_WARN("Tests will fail. Custom display string set to: ", test); diff --git a/src/dev_tools/utillib/sfos.cpp b/src/dev_tools/utillib/sfos.cpp index 15480a43a4..1514ba2592 100644 --- a/src/dev_tools/utillib/sfos.cpp +++ b/src/dev_tools/utillib/sfos.cpp @@ -183,7 +183,7 @@ string_q doCommand(const string_q& cmd, bool readStderr) { if (system(theCommand.c_str())) {} // Don't remove cruft. Silences compiler warnings // clang-format on - // Check twice for existence since the previous command creates the file but may take some time + // Check twice for existance since the previous command creates the file but may take some time waitForCreate(filename); string_q ret; asciiFileToString(filename, ret); diff --git a/src/dev_tools/utillib/toml.cpp b/src/dev_tools/utillib/toml.cpp index 1cd66a6495..64ac233186 100644 --- a/src/dev_tools/utillib/toml.cpp +++ b/src/dev_tools/utillib/toml.cpp @@ -223,7 +223,7 @@ string_q CToml::getConfigStr(const string_q& section, const string_q& key, const //------------------------------------------------------------------------- uint64_t CToml::getVersion(void) const { - // handle older ways of storing version. Note: after 0.6.0, always stored as [version]current + // handle older ways of stroring version. Note: after 0.6.0, always stored as [version]current string_q value = getConfigStr("version", "current", getConfigStr("", "version", "0.0.0")); uint16_t v1 = (uint16_t)str_2_Uint(nextTokenClear(value, '.')); uint16_t v2 = (uint16_t)str_2_Uint(nextTokenClear(value, '.')); diff --git a/src/examples/README.md b/src/examples/README.md index 826faf342c..e4e1a480b4 100644 --- a/src/examples/README.md +++ b/src/examples/README.md @@ -22,7 +22,7 @@ In the folder, `dynamic` are a few examples of building [custom traversers](http | Name | Description | | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | | [simple1](./dynamic/simple1/README.md) | A simple example of a dynamic traverser | -| [gasHole](./dynamic/gasHole/README.md) | A simple example show how to account for gas spent of successful and failed transactions | +| [gasHole](./dynamic/gasHole/README.md) | A simple example show how to account for gas spent of sucessful and failed transactions | | [balances](./dynamic/balances/README.md) | A simple example of producing a balance history for an account | | [filtering](./dynamic/filtering/README.md) | An example of filtering for particular data in an account's transaction history | | [recons](./dynamic/recons/README.md) | An example of reconciling an account's history at every transaction | From ad4b107757da58b2edb6c89a6b389b28b7491797 Mon Sep 17 00:00:00 2001 From: Thomas Jay Rush Date: Tue, 9 Apr 2024 21:51:11 -0400 Subject: [PATCH 18/18] Cleaning --- src/apps/chifra/internal/abis/doc.go | 2 +- src/apps/chifra/internal/blocks/doc.go | 2 +- src/apps/chifra/internal/blocks/output.go | 2 +- src/apps/chifra/internal/chunks/doc.go | 2 +- src/apps/chifra/internal/chunks/output.go | 2 +- src/apps/chifra/internal/config/doc.go | 2 +- src/apps/chifra/internal/config/output.go | 2 +- src/apps/chifra/internal/daemon/doc.go | 2 +- src/apps/chifra/internal/daemon/output.go | 2 +- src/apps/chifra/internal/explore/doc.go | 2 +- src/apps/chifra/internal/explore/output.go | 2 +- src/apps/chifra/internal/export/doc.go | 2 +- src/apps/chifra/internal/export/output.go | 2 +- src/apps/chifra/internal/init/doc.go | 2 +- src/apps/chifra/internal/init/output.go | 2 +- src/apps/chifra/internal/list/doc.go | 2 +- src/apps/chifra/internal/list/output.go | 2 +- src/apps/chifra/internal/logs/output.go | 2 +- src/apps/chifra/internal/monitors/output.go | 2 +- src/apps/chifra/internal/names/output.go | 2 +- src/apps/chifra/internal/receipts/output.go | 2 +- src/apps/chifra/internal/scrape/output.go | 2 +- src/apps/chifra/internal/slurp/output.go | 2 +- src/apps/chifra/internal/state/output.go | 2 +- src/apps/chifra/internal/status/output.go | 2 +- src/apps/chifra/internal/tokens/output.go | 2 +- src/apps/chifra/internal/traces/output.go | 2 +- src/apps/chifra/internal/transactions/output.go | 2 +- src/apps/chifra/internal/when/output.go | 2 +- src/dev_tools/goMaker/templates/api/description.txt | 2 +- .../templates/src_apps_chifra_internal_route_output.go.tmpl | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/apps/chifra/internal/abis/doc.go b/src/apps/chifra/internal/abis/doc.go index 58567c7d81..9e9abe5e1b 100644 --- a/src/apps/chifra/internal/abis/doc.go +++ b/src/apps/chifra/internal/abis/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package abisPkg handles the chifra abis command. The tool retrieves one or more ABI files for the given address(es). It searches for ABIs, sequentially, in the following locations: - the current working folder, - the TrueBlocks local cache, - Etherscan, - (in the future) ENS and Sourcify. While this tool may be used from the command line, its primary purpose is in support of the --articulate option for tools such as chifra export and chifra logs. If possible, the tool will follow proxied addresses searching for the ABI, but that does not always work. In that case, you may use the --proxy_for option. The --known option prints a list of semi-standard function signatures such as the ERC20 standard, ERC 721 standard, various functions from OpenZeppelin, various Uniswap functions, etc. As an optimization, the known signatures are searched first during articulation. The --encode option generates a 32-byte encoding for a given cannonical function or event signature. For functions, you may manually extract the first four bytes of the hash. The --find option is experimental. Please see the notes below for more information. +// The chifra abis tool retrieves one or more ABI files for the given address(es). It searches for ABIs, sequentially, in the following locations: - the current working folder, - the TrueBlocks local cache, - Etherscan, - (in the future) ENS and Sourcify. While this tool may be used from the command line, its primary purpose is in support of the --articulate option for tools such as chifra export and chifra logs. If possible, the tool will follow proxied addresses searching for the ABI, but that does not always work. In that case, you may use the --proxy_for option. The --known option prints a list of semi-standard function signatures such as the ERC20 standard, ERC 721 standard, various functions from OpenZeppelin, various Uniswap functions, etc. As an optimization, the known signatures are searched first during articulation. The --encode option generates a 32-byte encoding for a given cannonical function or event signature. For functions, you may manually extract the first four bytes of the hash. The --find option is experimental. Please see the notes below for more information. package abisPkg diff --git a/src/apps/chifra/internal/blocks/doc.go b/src/apps/chifra/internal/blocks/doc.go index 88b92f02de..ae3c91b499 100644 --- a/src/apps/chifra/internal/blocks/doc.go +++ b/src/apps/chifra/internal/blocks/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package blocksPkg handles the chifra blocks command. It retrieves block data from your Ethereum node or, if previously cached, from the TrueBlocks cache. You may specify multiple blocks per invocation. By default, queries the full transactional details of the block (including receipts). You may optionally retrieve only the transaction hashes in the block (which is significantly faster). Additionally, you may also use this tool to retrieve uncle blocks at a give height. Another useful feature of is the ability to extract address appearances from a block. TrueBlocks uses a similar feature internally to build its index of appearances. This type of data is very insightful when studying end user behavior and chain-wide adoption analysis. +// The chifra blocks tool retrieves block data from your Ethereum node or, if previously cached, from the TrueBlocks cache. You may specify multiple blocks per invocation. By default, chifra blocks queries the full transactional details of the block (including receipts). You may optionally retrieve only the transaction hashes in the block (which is significantly faster). Additionally, you may also use this tool to retrieve uncle blocks at a give height. Another useful feature of chifra blocks is the ability to extract address appearances from a block. TrueBlocks uses a similar feature internally to build its index of appearances. This type of data is very insightful when studying end user behavior and chain-wide adoption analysis. package blocksPkg diff --git a/src/apps/chifra/internal/blocks/output.go b/src/apps/chifra/internal/blocks/output.go index 9034714fb9..c6930b9d81 100644 --- a/src/apps/chifra/internal/blocks/output.go +++ b/src/apps/chifra/internal/blocks/output.go @@ -42,7 +42,7 @@ func ServeBlocks(w http.ResponseWriter, r *http.Request) error { return err } -// BlocksInternal handles the internal workings of the blocks command. Returns an error. +// BlocksInternal handles the internal workings of the blocks command. Returns an error. func (opts *BlocksOptions) BlocksInternal() error { var err error if err = opts.validateBlocks(); err != nil { diff --git a/src/apps/chifra/internal/chunks/doc.go b/src/apps/chifra/internal/chunks/doc.go index bb2e33ba05..6d44e7ddc7 100644 --- a/src/apps/chifra/internal/chunks/doc.go +++ b/src/apps/chifra/internal/chunks/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package chunksPkg handles the chifra chunks command. It 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. +// 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. package chunksPkg diff --git a/src/apps/chifra/internal/chunks/output.go b/src/apps/chifra/internal/chunks/output.go index f80d04c61a..7ffc69a104 100644 --- a/src/apps/chifra/internal/chunks/output.go +++ b/src/apps/chifra/internal/chunks/output.go @@ -50,7 +50,7 @@ func ServeChunks(w http.ResponseWriter, r *http.Request) error { return err } -// ChunksInternal handles the internal workings of the chunks command. Returns an error. +// ChunksInternal handles the internal workings of the chunks command. Returns an error. func (opts *ChunksOptions) ChunksInternal() error { var err error if err = opts.validateChunks(); err != nil { diff --git a/src/apps/chifra/internal/config/doc.go b/src/apps/chifra/internal/config/doc.go index c0db506702..469a12214f 100644 --- a/src/apps/chifra/internal/config/doc.go +++ b/src/apps/chifra/internal/config/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package configPkg handles the chifra config command. It allows you to manage the various TrueBlocks caches. You may list all of the caches, some of the cache, or even individual caches either in terse or full detail. The cache of interest is specified with the modes option. TrueBlocks maintains caches for the index of address appearances, named addresses, abi files, as well as other data including blockchain data, and address monitors. +// The chifra config program allows you to manage the various TrueBlocks caches. You may list all of the caches, some of the cache, or even individual caches either in terse or full detail. The cache of interest is specified with the modes option. TrueBlocks maintains caches for the index of address appearances, named addresses, abi files, as well as other data including blockchain data, and address monitors. package configPkg diff --git a/src/apps/chifra/internal/config/output.go b/src/apps/chifra/internal/config/output.go index ca5ac2f067..255b59f0f4 100644 --- a/src/apps/chifra/internal/config/output.go +++ b/src/apps/chifra/internal/config/output.go @@ -42,7 +42,7 @@ func ServeConfig(w http.ResponseWriter, r *http.Request) error { return err } -// ConfigInternal handles the internal workings of the config command. Returns an error. +// ConfigInternal handles the internal workings of the config command. Returns an error. func (opts *ConfigOptions) ConfigInternal() error { var err error if err = opts.validateConfig(); err != nil { diff --git a/src/apps/chifra/internal/daemon/doc.go b/src/apps/chifra/internal/daemon/doc.go index ccaa70320c..6831f158df 100644 --- a/src/apps/chifra/internal/daemon/doc.go +++ b/src/apps/chifra/internal/daemon/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package daemonPkg handles the chifra daemon command. It manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the command. In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server. The --grpc option turns on a GRPC server that may speed up certain command such as chifra names, although this option is experimental and therefore not recommended for production use. If the default port for the API server is in use, you may change it with the --port option. To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra --help on your command line to get help. See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options. +// chifra daemon manages chifra's API server. Each of the chifra commands along with all of its options, are provided not only by the command line, but also the API server. We call this process the flame server, which is written in Go. chifra serve is an alias for the chifra daemon command. In the future, this daemon may also manage other long-running processes such as chifra scrape and chifra monitors, but for now, it's only managing the API server. The --grpc option turns on a GRPC server that may speed up certain command such as chifra names, although this option is experimental and therefore not recommended for production use. If the default port for the API server is in use, you may change it with the --port option. To get help for any command, please see the API documentation on our website. But, you may also run chifra --help or chifra --help on your command line to get help. See below for an example of converting command line options to a call to the API. There's a one-to-one correspondence between the command line tools and options and the API routes and their options. package daemonPkg diff --git a/src/apps/chifra/internal/daemon/output.go b/src/apps/chifra/internal/daemon/output.go index 34aa6650a9..30473cd6d9 100644 --- a/src/apps/chifra/internal/daemon/output.go +++ b/src/apps/chifra/internal/daemon/output.go @@ -49,7 +49,7 @@ func ServeDaemon(w http.ResponseWriter, r *http.Request) error { return err } -// DaemonInternal handles the internal workings of the daemon command. Returns an error. +// DaemonInternal handles the internal workings of the daemon command. Returns an error. func (opts *DaemonOptions) DaemonInternal() error { var err error if err = opts.validateDaemon(); err != nil { diff --git a/src/apps/chifra/internal/explore/doc.go b/src/apps/chifra/internal/explore/doc.go index 1117681c78..195252c0af 100644 --- a/src/apps/chifra/internal/explore/doc.go +++ b/src/apps/chifra/internal/explore/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package explorePkg handles the chifra explore command. It opens Etherscan (and other explorers -- including our own) to the block identifier, transaction identifier, or address you specify. It's a handy (configurable) way to open an explorer from the command line, nothing more. +// chifra explore opens Etherscan (and other explorers -- including our own) to the block identifier, transaction identifier, or address you specify. It's a handy (configurable) way to open an explorer from the command line, nothing more. package explorePkg diff --git a/src/apps/chifra/internal/explore/output.go b/src/apps/chifra/internal/explore/output.go index f06e8a3717..06b9e3660c 100644 --- a/src/apps/chifra/internal/explore/output.go +++ b/src/apps/chifra/internal/explore/output.go @@ -44,7 +44,7 @@ func ServeExplore(w http.ResponseWriter, r *http.Request) error { return err } -// ExploreInternal handles the internal workings of the explore command. Returns an error. +// ExploreInternal handles the internal workings of the explore command. Returns an error. func (opts *ExploreOptions) ExploreInternal() error { var err error if err = opts.validateExplore(); err != nil { diff --git a/src/apps/chifra/internal/export/doc.go b/src/apps/chifra/internal/export/doc.go index 1ea1ba07fe..30c7488e90 100644 --- a/src/apps/chifra/internal/export/doc.go +++ b/src/apps/chifra/internal/export/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package exportPkg handles the chifra export command. It provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, completes the actual extraction of an address's transactional history from the node. You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results. You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish. By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you. +// The chifra export tools provides a major part of the functionality of the TrueBlocks system. Using the index of appearances created with chifra scrape and the list of transaction identifiers created with chifra list, chifra export completes the actual extraction of an address's transactional history from the node. You may use topics, fourbyte values at the start of a transaction's input data, and/or a log's source address or emitter to filter the results. You may also choose which portions of the Ethereum data structures (--transactions, --logs, --traces, etc.) as you wish. By default, the results of the extraction are delivered to your console, however, you may export the results to any database (with a little bit of work). The format of the data, its content and its destination are up to you. package exportPkg diff --git a/src/apps/chifra/internal/export/output.go b/src/apps/chifra/internal/export/output.go index bd02dcfd68..8055694829 100644 --- a/src/apps/chifra/internal/export/output.go +++ b/src/apps/chifra/internal/export/output.go @@ -43,7 +43,7 @@ func ServeExport(w http.ResponseWriter, r *http.Request) error { return err } -// ExportInternal handles the internal workings of the export command. Returns an error. +// ExportInternal handles the internal workings of the export command. Returns an error. func (opts *ExportOptions) ExportInternal() error { var err error if err = opts.validateExport(); err != nil { diff --git a/src/apps/chifra/internal/init/doc.go b/src/apps/chifra/internal/init/doc.go index ba3c4c0a54..2b6c367c29 100644 --- a/src/apps/chifra/internal/init/doc.go +++ b/src/apps/chifra/internal/init/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package initPkg handles the chifra init command. When invoked it 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. +// 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. package initPkg diff --git a/src/apps/chifra/internal/init/output.go b/src/apps/chifra/internal/init/output.go index b6a0cf3fd7..b6c398aed5 100644 --- a/src/apps/chifra/internal/init/output.go +++ b/src/apps/chifra/internal/init/output.go @@ -42,7 +42,7 @@ func ServeInit(w http.ResponseWriter, r *http.Request) error { return err } -// InitInternal handles the internal workings of the init command. Returns an error. +// InitInternal handles the internal workings of the init command. Returns an error. func (opts *InitOptions) InitInternal() error { var err error if err = opts.validateInit(); err != nil { diff --git a/src/apps/chifra/internal/list/doc.go b/src/apps/chifra/internal/list/doc.go index 8b53e8cfce..c3da5eb0e3 100644 --- a/src/apps/chifra/internal/list/doc.go +++ b/src/apps/chifra/internal/list/doc.go @@ -6,5 +6,5 @@ * the code inside of 'EXISTING_CODE' tags. */ -// Package listPkg handles the chifra list command. It takes one or more addresses, queries the index of appearances, and builds TrueBlocks monitors. A TrueBlocks monitor is a file that contains blockNumber.transactionIndex pairs (transaction identifiers) representing the history of the address. Because TrueBlocks only extracts data from the Ethereum node when it's requested, the first time you list an address it takes about a minute. Subsequent queries are much faster because TrueBlocks caches the results. Note that chifra list only queries the index, it does not extract the full transactional details. You may use chifra export for that. +// chifra list takes one or more addresses, queries the index of appearances, and builds TrueBlocks monitors. A TrueBlocks monitor is a file that contains blockNumber.transactionIndex pairs (transaction identifiers) representing the history of the address. Because TrueBlocks only extracts data from the Ethereum node when it's requested, the first time you list an address it takes about a minute. Subsequent queries are much faster because TrueBlocks caches the results. Note that chifra list only queries the index, it does not extract the full transactional details. You may use chifra export for that. package listPkg diff --git a/src/apps/chifra/internal/list/output.go b/src/apps/chifra/internal/list/output.go index d798a10e4a..2e8f3c4ff9 100644 --- a/src/apps/chifra/internal/list/output.go +++ b/src/apps/chifra/internal/list/output.go @@ -43,7 +43,7 @@ func ServeList(w http.ResponseWriter, r *http.Request) error { return err } -// ListInternal handles the internal workings of the list command. Returns an error. +// ListInternal handles the internal workings of the list command. Returns an error. func (opts *ListOptions) ListInternal() error { var err error if err = opts.validateList(); err != nil { diff --git a/src/apps/chifra/internal/logs/output.go b/src/apps/chifra/internal/logs/output.go index d5b0cf7c2f..e2478dde05 100644 --- a/src/apps/chifra/internal/logs/output.go +++ b/src/apps/chifra/internal/logs/output.go @@ -42,7 +42,7 @@ func ServeLogs(w http.ResponseWriter, r *http.Request) error { return err } -// LogsInternal handles the internal workings of the logs command. Returns an error. +// LogsInternal handles the internal workings of the logs command. Returns an error. func (opts *LogsOptions) LogsInternal() error { var err error if err = opts.validateLogs(); err != nil { diff --git a/src/apps/chifra/internal/monitors/output.go b/src/apps/chifra/internal/monitors/output.go index fe8aba7d2c..e11cc0fb98 100644 --- a/src/apps/chifra/internal/monitors/output.go +++ b/src/apps/chifra/internal/monitors/output.go @@ -64,7 +64,7 @@ func ServeMonitors(w http.ResponseWriter, r *http.Request) error { return err } -// MonitorsInternal handles the internal workings of the monitors command. Returns an error. +// MonitorsInternal handles the internal workings of the monitors command. Returns an error. func (opts *MonitorsOptions) MonitorsInternal() error { var err error if err = opts.validateMonitors(); err != nil { diff --git a/src/apps/chifra/internal/names/output.go b/src/apps/chifra/internal/names/output.go index fd27261150..d490bd8d00 100644 --- a/src/apps/chifra/internal/names/output.go +++ b/src/apps/chifra/internal/names/output.go @@ -54,7 +54,7 @@ func ServeNames(w http.ResponseWriter, r *http.Request) error { return err } -// NamesInternal handles the internal workings of the names command. Returns an error. +// NamesInternal handles the internal workings of the names command. Returns an error. func (opts *NamesOptions) NamesInternal() error { var err error if err = opts.validateNames(); err != nil { diff --git a/src/apps/chifra/internal/receipts/output.go b/src/apps/chifra/internal/receipts/output.go index dfa3bd3270..c3b62214c9 100644 --- a/src/apps/chifra/internal/receipts/output.go +++ b/src/apps/chifra/internal/receipts/output.go @@ -42,7 +42,7 @@ func ServeReceipts(w http.ResponseWriter, r *http.Request) error { return err } -// ReceiptsInternal handles the internal workings of the receipts command. Returns an error. +// ReceiptsInternal handles the internal workings of the receipts command. Returns an error. func (opts *ReceiptsOptions) ReceiptsInternal() error { var err error if err = opts.validateReceipts(); err != nil { diff --git a/src/apps/chifra/internal/scrape/output.go b/src/apps/chifra/internal/scrape/output.go index 2f7114767e..99ef8759c7 100644 --- a/src/apps/chifra/internal/scrape/output.go +++ b/src/apps/chifra/internal/scrape/output.go @@ -44,7 +44,7 @@ func ServeScrape(w http.ResponseWriter, r *http.Request) error { return err } -// ScrapeInternal handles the internal workings of the scrape command. Returns an error. +// ScrapeInternal handles the internal workings of the scrape command. Returns an error. func (opts *ScrapeOptions) ScrapeInternal() error { var err error if err = opts.validateScrape(); err != nil { diff --git a/src/apps/chifra/internal/slurp/output.go b/src/apps/chifra/internal/slurp/output.go index 9c63cee5e8..25e1363a42 100644 --- a/src/apps/chifra/internal/slurp/output.go +++ b/src/apps/chifra/internal/slurp/output.go @@ -42,7 +42,7 @@ func ServeSlurp(w http.ResponseWriter, r *http.Request) error { return err } -// SlurpInternal handles the internal workings of the slurp command. Returns an error. +// SlurpInternal handles the internal workings of the slurp command. Returns an error. func (opts *SlurpOptions) SlurpInternal() error { var err error if err = opts.validateSlurp(); err != nil { diff --git a/src/apps/chifra/internal/state/output.go b/src/apps/chifra/internal/state/output.go index fbaba6bda7..fc3316fe46 100644 --- a/src/apps/chifra/internal/state/output.go +++ b/src/apps/chifra/internal/state/output.go @@ -42,7 +42,7 @@ func ServeState(w http.ResponseWriter, r *http.Request) error { return err } -// StateInternal handles the internal workings of the state command. Returns an error. +// StateInternal handles the internal workings of the state command. Returns an error. func (opts *StateOptions) StateInternal() error { var err error if err = opts.validateState(); err != nil { diff --git a/src/apps/chifra/internal/status/output.go b/src/apps/chifra/internal/status/output.go index b7f6ea4dd2..f2944d7579 100644 --- a/src/apps/chifra/internal/status/output.go +++ b/src/apps/chifra/internal/status/output.go @@ -42,7 +42,7 @@ func ServeStatus(w http.ResponseWriter, r *http.Request) error { return err } -// StatusInternal handles the internal workings of the status command. Returns an error. +// StatusInternal handles the internal workings of the status command. Returns an error. func (opts *StatusOptions) StatusInternal() error { var err error if err = opts.validateStatus(); err != nil { diff --git a/src/apps/chifra/internal/tokens/output.go b/src/apps/chifra/internal/tokens/output.go index 901883920b..e92a5e8d26 100644 --- a/src/apps/chifra/internal/tokens/output.go +++ b/src/apps/chifra/internal/tokens/output.go @@ -42,7 +42,7 @@ func ServeTokens(w http.ResponseWriter, r *http.Request) error { return err } -// TokensInternal handles the internal workings of the tokens command. Returns an error. +// TokensInternal handles the internal workings of the tokens command. Returns an error. func (opts *TokensOptions) TokensInternal() error { var err error if err = opts.validateTokens(); err != nil { diff --git a/src/apps/chifra/internal/traces/output.go b/src/apps/chifra/internal/traces/output.go index 89c50a25b1..c8ac787217 100644 --- a/src/apps/chifra/internal/traces/output.go +++ b/src/apps/chifra/internal/traces/output.go @@ -42,7 +42,7 @@ func ServeTraces(w http.ResponseWriter, r *http.Request) error { return err } -// TracesInternal handles the internal workings of the traces command. Returns an error. +// TracesInternal handles the internal workings of the traces command. Returns an error. func (opts *TracesOptions) TracesInternal() error { var err error if err = opts.validateTraces(); err != nil { diff --git a/src/apps/chifra/internal/transactions/output.go b/src/apps/chifra/internal/transactions/output.go index e5161548f2..f7faa68190 100644 --- a/src/apps/chifra/internal/transactions/output.go +++ b/src/apps/chifra/internal/transactions/output.go @@ -42,7 +42,7 @@ func ServeTransactions(w http.ResponseWriter, r *http.Request) error { return err } -// TransactionsInternal handles the internal workings of the transactions command. Returns an error. +// TransactionsInternal handles the internal workings of the transactions command. Returns an error. func (opts *TransactionsOptions) TransactionsInternal() error { var err error if err = opts.validateTransactions(); err != nil { diff --git a/src/apps/chifra/internal/when/output.go b/src/apps/chifra/internal/when/output.go index 4352520cd5..db4d70642f 100644 --- a/src/apps/chifra/internal/when/output.go +++ b/src/apps/chifra/internal/when/output.go @@ -43,7 +43,7 @@ func ServeWhen(w http.ResponseWriter, r *http.Request) error { return err } -// WhenInternal handles the internal workings of the when command. Returns an error. +// WhenInternal handles the internal workings of the when command. Returns an error. func (opts *WhenOptions) WhenInternal() error { var err error if err = opts.validateWhen(); err != nil { diff --git a/src/dev_tools/goMaker/templates/api/description.txt b/src/dev_tools/goMaker/templates/api/description.txt index aa4fc7cb8e..ede1080831 100644 --- a/src/dev_tools/goMaker/templates/api/description.txt +++ b/src/dev_tools/goMaker/templates/api/description.txt @@ -47,7 +47,7 @@ "http://localhost:8080/blocks?blocks=100-110&cache=true" ``` - Cacheing speeds up repeat queries significantly. The cache options are + Caching speeds up repeat queries significantly. The cache options are particularly useful for calls to data-rich endpoints, like most endpoints in the "Accounts" collection. diff --git a/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_output.go.tmpl b/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_output.go.tmpl index b659a0caae..3d4e6cdc2f 100644 --- a/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_output.go.tmpl +++ b/src/dev_tools/goMaker/templates/src_apps_chifra_internal_route_output.go.tmpl @@ -33,7 +33,7 @@ func Serve{{.Proper}}(w http.ResponseWriter, r *http.Request) error { return err } -// {{.Proper}}Internal handles the internal workings of the {{.Route}} command. Returns an error. +// {{.Proper}}Internal handles the internal workings of the {{.Route}} command. Returns an error. func (opts *{{.Proper}}Options) {{.Proper}}Internal() error { var err error if err = opts.validate{{.Proper}}(); err != nil {