Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unseen transactions rebroadcasting interval setting #598

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions cmd/arc/services/metamorph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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),
Expand Down
27 changes: 14 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 11 additions & 10 deletions config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion config/example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Loading