diff --git a/cmd/arc/services/metamorph.go b/cmd/arc/services/metamorph.go index 54c7a82ca..82df836cc 100644 --- a/cmd/arc/services/metamorph.go +++ b/cmd/arc/services/metamorph.go @@ -10,25 +10,25 @@ import ( "strconv" "time" + "github.com/libsv/go-p2p" + "github.com/ordishs/go-bitcoin" + "github.com/sirupsen/logrus" + "google.golang.org/grpc" + "google.golang.org/grpc/health/grpc_health_v1" + "google.golang.org/grpc/reflection" + + "github.com/bitcoin-sv/arc/config" + "github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api" "github.com/bitcoin-sv/arc/internal/callbacker/callbacker_api" "github.com/bitcoin-sv/arc/internal/grpc_opts" "github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_core" "github.com/bitcoin-sv/arc/internal/message_queue/nats/client/nats_jetstream" "github.com/bitcoin-sv/arc/internal/message_queue/nats/nats_connection" - - "github.com/bitcoin-sv/arc/config" - "github.com/bitcoin-sv/arc/internal/blocktx/blocktx_api" "github.com/bitcoin-sv/arc/internal/metamorph" "github.com/bitcoin-sv/arc/internal/metamorph/metamorph_api" "github.com/bitcoin-sv/arc/internal/metamorph/store" "github.com/bitcoin-sv/arc/internal/metamorph/store/postgresql" "github.com/bitcoin-sv/arc/internal/version" - "github.com/libsv/go-p2p" - "github.com/ordishs/go-bitcoin" - "github.com/sirupsen/logrus" - "google.golang.org/grpc" - "google.golang.org/grpc/health/grpc_health_v1" - "google.golang.org/grpc/reflection" ) const ( @@ -87,6 +87,7 @@ func StartMetamorph(logger *slog.Logger, arcConfig *config.ArcConfig) (func(), e processorOpts := []metamorph.Option{ metamorph.WithCacheExpiryTime(mtmConfig.ProcessorCacheExpiryTime), + metamorph.WithProcessExpiredTxsInterval(mtmConfig.UnseenTransactionRebroadcastingInterval), metamorph.WithSeenOnNetworkTxTimeUntil(mtmConfig.CheckSeenOnNetworkOlderThan), metamorph.WithSeenOnNetworkTxTime(mtmConfig.CheckSeenOnNetworkPeriod), metamorph.WithProcessorLogger(procLogger), diff --git a/config/config.go b/config/config.go index 4232e73b4..aa5fab542 100644 --- a/config/config.go +++ b/config/config.go @@ -57,19 +57,20 @@ type PeerPortConfig struct { } type MetamorphConfig struct { - ListenAddr string `mapstructure:"listenAddr"` - DialAddr string `mapstructure:"dialAddr"` - Db *DbConfig `mapstructure:"db"` - ProcessorCacheExpiryTime time.Duration `mapstructure:"processorCacheExpiryTime"` - MaxRetries int `mapstructure:"maxRetries"` - ProcessStatusUpdateInterval time.Duration `mapstructure:"processStatusUpdateInterval"` - CheckSeenOnNetworkOlderThan time.Duration `mapstructure:"checkSeenOnNetworkOlderThan"` - CheckSeenOnNetworkPeriod time.Duration `mapstructure:"checkSeenOnNetworkPeriod"` - MonitorPeers bool `mapstructure:"monitorPeers"` - CheckUtxos bool `mapstructure:"checkUtxos"` - Health *HealthConfig `mapstructure:"health"` - RejectCallbackContaining []string `mapstructure:"rejectCallbackContaining"` - Stats *StatsConfig `mapstructure:"stats"` + ListenAddr string `mapstructure:"listenAddr"` + DialAddr string `mapstructure:"dialAddr"` + Db *DbConfig `mapstructure:"db"` + ProcessorCacheExpiryTime time.Duration `mapstructure:"processorCacheExpiryTime"` + UnseenTransactionRebroadcastingInterval time.Duration `mapstructure:"unseenTransactionRebroadcastingInterval"` + MaxRetries int `mapstructure:"maxRetries"` + ProcessStatusUpdateInterval time.Duration `mapstructure:"processStatusUpdateInterval"` + CheckSeenOnNetworkOlderThan time.Duration `mapstructure:"checkSeenOnNetworkOlderThan"` + CheckSeenOnNetworkPeriod time.Duration `mapstructure:"checkSeenOnNetworkPeriod"` + MonitorPeers bool `mapstructure:"monitorPeers"` + CheckUtxos bool `mapstructure:"checkUtxos"` + Health *HealthConfig `mapstructure:"health"` + RejectCallbackContaining []string `mapstructure:"rejectCallbackContaining"` + Stats *StatsConfig `mapstructure:"stats"` } type BlocktxConfig struct { diff --git a/config/defaults.go b/config/defaults.go index 5778d7c3a..33abe1195 100644 --- a/config/defaults.go +++ b/config/defaults.go @@ -72,16 +72,17 @@ func getPeersConfig() []*PeerConfig { func getMetamorphConfig() *MetamorphConfig { return &MetamorphConfig{ - ListenAddr: "localhost:8001", - DialAddr: "localhost:8001", - Db: getDbConfig("metamorph"), - ProcessorCacheExpiryTime: 24 * time.Hour, - MaxRetries: 1000, - ProcessStatusUpdateInterval: 5 * time.Second, - CheckSeenOnNetworkOlderThan: 3 * time.Hour, - CheckSeenOnNetworkPeriod: 4 * time.Hour, - MonitorPeers: false, - CheckUtxos: false, + ListenAddr: "localhost:8001", + DialAddr: "localhost:8001", + Db: getDbConfig("metamorph"), + ProcessorCacheExpiryTime: 24 * time.Hour, + UnseenTransactionRebroadcastingInterval: 60 * time.Second, + MaxRetries: 1000, + ProcessStatusUpdateInterval: 5 * time.Second, + CheckSeenOnNetworkOlderThan: 3 * time.Hour, + CheckSeenOnNetworkPeriod: 4 * time.Hour, + MonitorPeers: false, + CheckUtxos: false, Health: &HealthConfig{ SeverDialAddr: "localhost:8005", MinimumHealthyConnections: 2, diff --git a/config/example_config.yaml b/config/example_config.yaml index 6581ee96d..dc666bd30 100644 --- a/config/example_config.yaml +++ b/config/example_config.yaml @@ -47,6 +47,7 @@ metamorph: maxOpenConns: 80 # maximum open connections sslMode: disable processorCacheExpiryTime: 24h # time after which processor cache is cleaned + unseenTransactionRebroadcastingInterval: 60s # time interval in which unseen transactions are re-broadcasted maxRetries: 1000 # maximum number of times a transaction is re-broadcasted processStatusUpdateInterval: 5s # interval of processing status updates checkSeenOnNetworkOlderThan: 3h # transactions with SEEN_ON_NETWORK status will be re-requested from blocktx which are older than checkSeenOnNetworkOlderThan @@ -143,4 +144,3 @@ callbacker: quarantinePolicy: baseDuration: 5m # initial duration a callback and its receiver is quarantined after failure permQuarantineAfter: 24h # maximum time a callback can remain unsent before it's put in permanent quarantine - \ No newline at end of file