@@ -22,8 +22,6 @@ import (
2222 "github.com/ethereum/go-ethereum/p2p/enode"
2323 "github.com/ethereum/go-ethereum/p2p/nat"
2424 "github.com/ethereum/go-ethereum/rpc"
25- "github.com/prometheus/client_golang/prometheus"
26- "github.com/prometheus/client_golang/prometheus/promauto"
2725 "github.com/prometheus/client_golang/prometheus/promhttp"
2826 "github.com/rs/zerolog/log"
2927 "github.com/spf13/cobra"
6058 BroadcastWorkers int
6159 TxBatchTimeout time.Duration
6260 TxBroadcastQueueSize int
61+ MaxTxPacketSize int
62+ MaxQueuedTxs int
6363 ShouldRunPprof bool
6464 PprofPort uint
6565 ShouldRunPrometheus bool
@@ -200,12 +200,7 @@ var SensorCmd = &cobra.Command{
200200 TD : rpcBlock .TotalDifficulty .ToBigInt (),
201201 }
202202
203- peersGauge := promauto .NewGauge (prometheus.GaugeOpts {
204- Namespace : "sensor" ,
205- Name : "peers" ,
206- Help : "The number of peers the sensor is connected to" ,
207- })
208-
203+ peersGauge := p2p .NewPeersGauge ()
209204 metrics := p2p .NewBlockMetrics (head .Block )
210205
211206 // Create peer connection manager for broadcasting transactions
@@ -223,6 +218,8 @@ var SensorCmd = &cobra.Command{
223218 BroadcastWorkers : inputSensorParams .BroadcastWorkers ,
224219 TxBatchTimeout : inputSensorParams .TxBatchTimeout ,
225220 TxBroadcastQueueSize : inputSensorParams .TxBroadcastQueueSize ,
221+ MaxTxPacketSize : inputSensorParams .MaxTxPacketSize ,
222+ MaxQueuedTxs : inputSensorParams .MaxQueuedTxs ,
226223 })
227224
228225 opts := p2p.EthProtocolOptions {
@@ -499,7 +496,9 @@ will result in less chance of missing data but can significantly increase memory
499496 f .BoolVar (& inputSensorParams .ShouldBroadcastBlockHashes , "broadcast-block-hashes" , false , "broadcast block hashes to peers" )
500497 f .IntVar (& inputSensorParams .BroadcastWorkers , "broadcast-workers" , 4 , "number of concurrent broadcast workers" )
501498 f .DurationVar (& inputSensorParams .TxBatchTimeout , "tx-batch-timeout" , 500 * time .Millisecond , "timeout for batching transactions before broadcast" )
502- f .IntVar (& inputSensorParams .TxBroadcastQueueSize , "tx-broadcast-queue-size" , 100000 , "capacity of transaction broadcast queue" )
499+ f .IntVar (& inputSensorParams .TxBroadcastQueueSize , "tx-broadcast-queue-size" , 100_000 , "capacity of transaction broadcast queue" )
500+ f .IntVar (& inputSensorParams .MaxTxPacketSize , "max-tx-packet-size" , 100 * 1024 , "target size in bytes for transaction broadcast packets" )
501+ f .IntVar (& inputSensorParams .MaxQueuedTxs , "max-queued-txs" , 4096 , "maximum transaction announcements to queue per peer" )
503502 f .BoolVar (& inputSensorParams .ShouldRunPprof , "pprof" , false , "run pprof server" )
504503 f .UintVar (& inputSensorParams .PprofPort , "pprof-port" , 6060 , "port pprof runs on" )
505504 f .BoolVar (& inputSensorParams .ShouldRunPrometheus , "prom" , true , "run Prometheus server" )
0 commit comments