cmd

package
v0.0.0-...-e16fa07 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var WatchCmd = &cobra.Command{
	Use:   "watch",
	Short: "Watch for Whales on the BitcoinCash network",
	Long: `This command will watch for large amounts of BCH being transferred on-chain.
		It will then tweet about these transactions.`,

	RunE: func(cmd *cobra.Command, args []string) error {
		logger, err := getLogger()
		if err != nil {
			return err
		}

		ctx, cancel := context.WithCancel(context.Background())
		defer cancel()
		go listenExitCommand(logger, cancel)
		monitor := createMonitoringClient(ctx, logger)

		// start all main workers in separate goroutines
		var wg sync.WaitGroup

		if monitor != nil {
			wg.Add(1)
			go func() {
				defer wg.Done()
				monitor.ListenHttp(ctx)
			}()
		}

		counter, err := txcounter.NewTxCounter(&txcounter.TxCounterConfig{
			AverageTime: time.Duration(viper.GetInt("Average.TransactionAverageTimeH")) * time.Hour,
		}, ctx, logger, monitor)
		if err != nil {
			logger.Fatalf("Error creating TX counter: %+v", err)
		}
		go counter.ScheduleCleanupTransactions()

		wg.Add(1)
		go func() {
			defer wg.Done()
			watchTransactionsRest(counter, ctx, logger, monitor)
		}()

		wg.Wait()

		err = counter.WriteTransactionsFile()
		if err != nil {
			logger.Errorf("Error writing transaction data to disk on shutdown %+v", err)
		}

		return nil
	},
}

Functions

func Execute

func Execute()

Execute root command

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL