diff --git a/client_options.go b/client_options.go index b9c07d3f..0faab0a4 100644 --- a/client_options.go +++ b/client_options.go @@ -1,7 +1,6 @@ package bux import ( - "context" "database/sql" "net/http" "net/url" @@ -633,24 +632,6 @@ func WithExcludedProviders(providers []string) ClientOps { } } -// WithMonitoring will create a new monitorConfig interface with the given options -func WithMonitoring(ctx context.Context, monitorOptions *chainstate.MonitorOptions) ClientOps { - return func(c *clientOptions) { - if monitorOptions != nil { - c.chainstate.options = append(c.chainstate.options, chainstate.WithMonitoring(ctx, monitorOptions)) - } - } -} - -// WithMonitoringInterface will set the interface to use for monitoring the blockchain -func WithMonitoringInterface(monitor chainstate.MonitorService) ClientOps { - return func(c *clientOptions) { - if monitor != nil { - c.chainstate.options = append(c.chainstate.options, chainstate.WithMonitoringInterface(monitor)) - } - } -} - // ----------------------------------------------------------------- // NOTIFICATIONS // ----------------------------------------------------------------- diff --git a/cron_job_declarations.go b/cron_job_declarations.go index feeafd9a..f9e77f09 100644 --- a/cron_job_declarations.go +++ b/cron_job_declarations.go @@ -28,7 +28,7 @@ func (c *Client) cronJobs() taskmanager.CronJobs { return taskmanager.CronJobs{ CronJobNameDraftTransactionCleanUp: { - Period: defaultMonitorHeartbeat * time.Second, + Period: 60 * time.Second, Handler: handler(taskCleanupDraftTransactions), }, CronJobNameIncomingTransaction: { diff --git a/definitions.go b/definitions.go index aec72e2c..8fc5ecc8 100644 --- a/definitions.go +++ b/definitions.go @@ -14,7 +14,6 @@ const ( defaultDatabaseReadTimeout = 20 * time.Second // For all "GET" or "SELECT" methods defaultDraftTxExpiresIn = 20 * time.Second // Default TTL for draft transactions defaultHTTPTimeout = 20 * time.Second // Default timeout for HTTP requests - defaultMonitorHeartbeat = 60 // in Seconds (heartbeat for active monitor) defaultMonitorSleep = 2 * time.Second defaultMonitorLockTTL = 10 // in seconds - should be larger than defaultMonitorSleep defaultOverheadSize = uint64(8) // 8 bytes is the default overhead in a transaction = 4 bytes version + 4 bytes nLockTime diff --git a/examples/client/monitor/monitor.go b/examples/client/monitor/monitor.go deleted file mode 100644 index bdfe02d0..00000000 --- a/examples/client/monitor/monitor.go +++ /dev/null @@ -1,78 +0,0 @@ -package main - -import ( - "context" - "log" - "os" - "time" - - "github.com/mrz1836/go-datastore" - - "github.com/BuxOrg/bux" - "github.com/BuxOrg/bux/chainstate" -) - -func main() { - client, err := bux.NewClient( - context.Background(), // Set context - bux.WithSQLite(&datastore.SQLiteConfig{ // Load using a sqlite configuration - CommonConfig: datastore.CommonConfig{ - Debug: false, - MaxConnectionIdleTime: 10 * time.Second, - MaxConnectionTime: 10 * time.Second, - MaxIdleConnections: 10, - MaxOpenConnections: 10, - TablePrefix: "bux", - }, - }), - bux.WithMonitoring(context.Background(), &chainstate.MonitorOptions{ - AuthToken: os.Getenv("BUX_MONITOR_AUTH_TOKEN"), - BuxAgentURL: "wss://" + os.Getenv("BUX_MONITOR_URL"), - Debug: true, - FalsePositiveRate: 0, - LoadMonitoredDestinations: true, - LockID: "unique-lock-id-for-multiple-servers", - MaxNumberOfDestinations: 25000, - MonitorDays: 5, - ProcessorType: chainstate.FilterRegex, - SaveTransactionDestinations: false, - }), - - bux.WithDebugging(), // Enable debugging (verbose logs) - bux.WithChainstateOptions(true, true, true, true), // Broadcasting enabled by default - bux.WithAutoMigrate(bux.BaseModels...), - ) - if err != nil { - log.Fatalf(err.Error()) - } - defer func() { - _ = client.Close(context.Background()) - }() - - m := client.Chainstate().Monitor() - - // Create a new handler - handler := bux.NewMonitorHandler(context.Background(), client, m) - - // Start - if err = m.Start(context.Background(), &handler, func() { - // callback when the monitor stops - }); err != nil { - log.Fatalf(err.Error()) - } - - // Add a regex filter - if err = m.Add("006a", ""); err != nil { - log.Fatal(err.Error()) - } - - // Pause - time.Sleep(time.Second * 10) - - // Stop the monitor - if err = m.Stop(context.Background()); err != nil { - log.Fatalf(err.Error()) - } - time.Sleep(time.Second * 5) - log.Println("Complete!") -}