From c520da3e40d62cf017f6a7749abddd05a1716b66 Mon Sep 17 00:00:00 2001
From: Krzysztof Tomecki <152964795+chris-4chain@users.noreply.github.com>
Date: Thu, 21 Dec 2023 12:04:18 +0100
Subject: [PATCH 1/2] chore(BUX-416): remove WithMonitoring

---
 client_options.go                  | 19 --------
 cron_job_declarations.go           |  2 +-
 definitions.go                     |  1 -
 examples/client/monitor/monitor.go | 78 ------------------------------
 4 files changed, 1 insertion(+), 99 deletions(-)
 delete mode 100644 examples/client/monitor/monitor.go

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!")
-}

From af79fa95d314b38d68cb11fe270931f3c21cf8e8 Mon Sep 17 00:00:00 2001
From: Krzysztof Tomecki <152964795+chris-4chain@users.noreply.github.com>
Date: Thu, 21 Dec 2023 12:08:51 +0100
Subject: [PATCH 2/2] chore(BUX-416): bump version

---
 definitions.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/definitions.go b/definitions.go
index 8fc5ecc8..c8045314 100644
--- a/definitions.go
+++ b/definitions.go
@@ -23,7 +23,7 @@ const (
 	dustLimit                      = uint64(1)         // Dust limit
 	mongoTestVersion               = "6.0.4"           // Mongo Testing Version
 	sqliteTestVersion              = "3.37.0"          // SQLite Testing Version (dummy version for now)
-	version                        = "v0.9.0"          // bux version
+	version                        = "v0.9.1"          // bux version
 )
 
 // All the base models