github.com/TrueBlocks/trueblocks-core/src/apps/chifra@v0.0.0-20241022031540-b362680128f7/internal/when/handle_ts_count.go (about) 1 // Copyright 2021 The TrueBlocks Authors. All rights reserved. 2 // Use of this source code is governed by a license that can 3 // be found in the LICENSE file. 4 5 package whenPkg 6 7 import ( 8 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 9 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/tslib" 10 "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 11 ) 12 13 func (opts *WhenOptions) HandleTimestampsCount(rCtx *output.RenderCtx) error { 14 chain := opts.Globals.Chain 15 testMode := opts.Globals.TestMode 16 17 fetchData := func(modelChan chan types.Modeler, errorChan chan error) { 18 if count, err := tslib.NTimestamps(chain); err != nil { 19 errorChan <- err 20 return 21 22 } else { 23 if testMode { 24 count = 5000000 25 } 26 27 s := types.Count{ 28 Count: uint64(count), 29 } 30 31 modelChan <- &s 32 } 33 } 34 35 return output.StreamMany(rCtx, fetchData, opts.Globals.OutputOpts()) 36 }