@@ -84,6 +84,43 @@ type ManagerCfg struct {
8484 ErrChan chan <- error
8585}
8686
87+ // Validate validates the ManagerCfg.
88+ func (m * ManagerCfg ) Validate () error {
89+ if m .Chain == nil {
90+ return fmt .Errorf ("chain is required" )
91+ }
92+
93+ if m .AssetLookup == nil {
94+ return fmt .Errorf ("asset lookup is required" )
95+ }
96+
97+ if m .Lnd == nil {
98+ return fmt .Errorf ("lnd is required" )
99+ }
100+
101+ if m .SupplyCommitView == nil {
102+ return fmt .Errorf ("supply commit view is required" )
103+ }
104+
105+ if m .SupplyTreeView == nil {
106+ return fmt .Errorf ("supply tree view is required" )
107+ }
108+
109+ if m .GroupFetcher == nil {
110+ return fmt .Errorf ("group fetcher is required" )
111+ }
112+
113+ if m .IssuanceSubscriptions == nil {
114+ return fmt .Errorf ("issuance subscriptions is required" )
115+ }
116+
117+ if m .DaemonAdapters == nil {
118+ return fmt .Errorf ("daemon adapters is required" )
119+ }
120+
121+ return nil
122+ }
123+
87124// Manager is a manager for multiple supply verifier state machines, one for
88125// each asset group. It is responsible for starting and stopping the state
89126// machines, as well as forwarding events to them.
@@ -104,14 +141,18 @@ type Manager struct {
104141}
105142
106143// NewManager creates a new multi state machine manager.
107- func NewManager (cfg ManagerCfg ) * Manager {
144+ func NewManager (cfg ManagerCfg ) (* Manager , error ) {
145+ if err := cfg .Validate (); err != nil {
146+ return nil , fmt .Errorf ("invalid config: %w" , err )
147+ }
148+
108149 return & Manager {
109150 cfg : cfg ,
110151 ContextGuard : & fn.ContextGuard {
111152 DefaultTimeout : DefaultTimeout ,
112153 Quit : make (chan struct {}),
113154 },
114- }
155+ }, nil
115156}
116157
117158// InitStateMachines initializes state machines for all asset groups that
0 commit comments