@@ -587,6 +587,16 @@ type Config struct {
587587 // up and this filter header state has diverged, then it'll remove the
588588 // current on disk filter headers to sync them anew.
589589 AssertFilterHeader * headerfs.FilterHeader
590+
591+ // BroadcastTimeout is the amount of time we'll wait before giving up on
592+ // a transaction broadcast attempt. Broadcasting transactions consists
593+ // of three steps:
594+ //
595+ // 1. Neutrino sends an inv for the transaction.
596+ // 2. The recipient node determines if the inv is known, and if it's
597+ // not, replies with a getdata message.
598+ // 3. Neutrino sends the raw transaction.
599+ BroadcastTimeout time.Duration
590600}
591601
592602// peerSubscription holds a peer subscription which we'll notify about any
@@ -649,12 +659,19 @@ type ChainService struct {
649659
650660 nameResolver func (string ) ([]net.IP , error )
651661 dialer func (net.Addr ) (net.Conn , error )
662+
663+ broadcastTimeout time.Duration
652664}
653665
654666// NewChainService returns a new chain service configured to connect to the
655667// bitcoin network type specified by chainParams. Use start to begin syncing
656668// with peers.
657669func NewChainService (cfg Config ) (* ChainService , error ) {
670+ // Use the default broadcast timeout if one isn't provided.
671+ if cfg .BroadcastTimeout == 0 {
672+ cfg .BroadcastTimeout = pushtx .DefaultBroadcastTimeout
673+ }
674+
658675 // First, we'll sort out the methods that we'll use to established
659676 // outbound TCP connections, as well as perform any DNS queries.
660677 //
@@ -702,6 +719,7 @@ func NewChainService(cfg Config) (*ChainService, error) {
702719 nameResolver : nameResolver ,
703720 dialer : dialer ,
704721 persistToDisk : cfg .PersistToDisk ,
722+ broadcastTimeout : cfg .BroadcastTimeout ,
705723 }
706724 s .workManager = query .New (& query.Config {
707725 ConnectedPeers : s .ConnectedPeers ,
0 commit comments