@@ -33,10 +33,10 @@ type DaemonAdapters interface {
33
33
Stop () error
34
34
}
35
35
36
- // MultiStateMachineManagerCfg is the configuration for the
37
- // MultiStateMachineManager . It contains all the dependencies needed to
36
+ // ManagerCfg is the configuration for the
37
+ // Manager . It contains all the dependencies needed to
38
38
// manage multiple supply commitment state machines, one for each asset group.
39
- type MultiStateMachineManagerCfg struct {
39
+ type ManagerCfg struct {
40
40
// TreeView is the interface that allows the state machine to obtain an
41
41
// up to date snapshot of the root supply tree, and the relevant set of
42
42
// subtrees.
@@ -71,12 +71,12 @@ type MultiStateMachineManagerCfg struct {
71
71
ChainParams chaincfg.Params
72
72
}
73
73
74
- // MultiStateMachineManager is a manager for multiple supply commitment state
74
+ // Manager is a manager for multiple supply commitment state
75
75
// machines, one for each asset group. It is responsible for starting and
76
76
// stopping the state machines, as well as forwarding sending events to them.
77
- type MultiStateMachineManager struct {
77
+ type Manager struct {
78
78
// cfg is the configuration for the multi state machine manager.
79
- cfg MultiStateMachineManagerCfg
79
+ cfg ManagerCfg
80
80
81
81
// smCache is a cache that maps asset group public keys to their
82
82
// supply commitment state machines.
@@ -90,11 +90,9 @@ type MultiStateMachineManager struct {
90
90
stopOnce sync.Once
91
91
}
92
92
93
- // NewMultiStateMachineManager creates a new multi state machine manager.
94
- func NewMultiStateMachineManager (
95
- cfg MultiStateMachineManagerCfg ) * MultiStateMachineManager {
96
-
97
- return & MultiStateMachineManager {
93
+ // NewManager creates a new multi state machine manager.
94
+ func NewManager (cfg ManagerCfg ) * Manager {
95
+ return & Manager {
98
96
cfg : cfg ,
99
97
ContextGuard : & fn.ContextGuard {
100
98
DefaultTimeout : DefaultTimeout ,
@@ -104,7 +102,7 @@ func NewMultiStateMachineManager(
104
102
}
105
103
106
104
// Start starts the multi state machine manager.
107
- func (m * MultiStateMachineManager ) Start () error {
105
+ func (m * Manager ) Start () error {
108
106
m .startOnce .Do (func () {
109
107
// Initialize the state machine cache.
110
108
m .smCache = newStateMachineCache ()
@@ -115,7 +113,7 @@ func (m *MultiStateMachineManager) Start() error {
115
113
116
114
// Stop stops the multi state machine manager, which in turn stops all asset
117
115
// group key specific supply commitment state machines.
118
- func (m * MultiStateMachineManager ) Stop () error {
116
+ func (m * Manager ) Stop () error {
119
117
m .stopOnce .Do (func () {
120
118
// Cancel the state machine context to signal all state machines
121
119
// to stop.
@@ -131,7 +129,7 @@ func (m *MultiStateMachineManager) Stop() error {
131
129
// fetchStateMachine retrieves a state machine from the cache or creates a
132
130
// new one if it doesn't exist. If a new state machine is created, it is also
133
131
// started.
134
- func (m * MultiStateMachineManager ) fetchStateMachine (
132
+ func (m * Manager ) fetchStateMachine (
135
133
assetSpec asset.Specifier ) (* StateMachine , error ) {
136
134
137
135
groupKey , err := assetSpec .UnwrapGroupKeyOrErr ()
@@ -212,13 +210,13 @@ func (m *MultiStateMachineManager) fetchStateMachine(
212
210
// SendEvent sends an event to the state machine associated with the given asset
213
211
// specifier. If a state machine for the asset group does not exist, it will be
214
212
// created and started.
215
- func (m * MultiStateMachineManager ) SendEvent (ctx context.Context ,
213
+ func (m * Manager ) SendEvent (ctx context.Context ,
216
214
assetSpec asset.Specifier , event Event ) error {
217
215
218
216
sm , err := m .fetchStateMachine (assetSpec )
219
217
if err != nil {
220
- return fmt .Errorf ("unable to get or create state " +
221
- "machine: %w" , err )
218
+ return fmt .Errorf ("unable to get or create state machine: %w" ,
219
+ err )
222
220
}
223
221
224
222
sm .SendEvent (ctx , event )
@@ -228,7 +226,7 @@ func (m *MultiStateMachineManager) SendEvent(ctx context.Context,
228
226
// CanHandle determines if the state machine associated with the given asset
229
227
// specifier can handle the given message. If a state machine for the asset
230
228
// group does not exist, it will be created and started.
231
- func (m * MultiStateMachineManager ) CanHandle (assetSpec asset.Specifier ,
229
+ func (m * Manager ) CanHandle (assetSpec asset.Specifier ,
232
230
msg msgmux.PeerMsg ) (bool , error ) {
233
231
234
232
sm , err := m .fetchStateMachine (assetSpec )
@@ -243,7 +241,7 @@ func (m *MultiStateMachineManager) CanHandle(assetSpec asset.Specifier,
243
241
// Name returns the name of the state machine associated with the given asset
244
242
// specifier. If a state machine for the asset group does not exist, it will be
245
243
// created and started.
246
- func (m * MultiStateMachineManager ) Name (
244
+ func (m * Manager ) Name (
247
245
assetSpec asset.Specifier ) (string , error ) {
248
246
249
247
sm , err := m .fetchStateMachine (assetSpec )
@@ -258,7 +256,7 @@ func (m *MultiStateMachineManager) Name(
258
256
// SendMessage sends a message to the state machine associated with the given
259
257
// asset specifier. If a state machine for the asset group does not exist, it
260
258
// will be created and started.
261
- func (m * MultiStateMachineManager ) SendMessage (ctx context.Context ,
259
+ func (m * Manager ) SendMessage (ctx context.Context ,
262
260
assetSpec asset.Specifier , msg msgmux.PeerMsg ) (bool , error ) {
263
261
264
262
sm , err := m .fetchStateMachine (assetSpec )
@@ -273,7 +271,7 @@ func (m *MultiStateMachineManager) SendMessage(ctx context.Context,
273
271
// CurrentState returns the current state of the state machine associated with
274
272
// the given asset specifier. If a state machine for the asset group does not
275
273
// exist, it will be created and started.
276
- func (m * MultiStateMachineManager ) CurrentState (assetSpec asset.Specifier ) (
274
+ func (m * Manager ) CurrentState (assetSpec asset.Specifier ) (
277
275
protofsm.State [Event , * Environment ], error ) {
278
276
279
277
sm , err := m .fetchStateMachine (assetSpec )
@@ -288,7 +286,7 @@ func (m *MultiStateMachineManager) CurrentState(assetSpec asset.Specifier) (
288
286
// RegisterStateEvents registers a state event subscriber with the state machine
289
287
// associated with the given asset specifier. If a state machine for the asset
290
288
// group does not exist, it will be created and started.
291
- func (m * MultiStateMachineManager ) RegisterStateEvents (
289
+ func (m * Manager ) RegisterStateEvents (
292
290
assetSpec asset.Specifier ) (StateSub , error ) {
293
291
294
292
sm , err := m .fetchStateMachine (assetSpec )
@@ -303,7 +301,7 @@ func (m *MultiStateMachineManager) RegisterStateEvents(
303
301
// RemoveStateSub removes a state event subscriber from the state machine
304
302
// associated with the given asset specifier. If a state machine for the asset
305
303
// group does not exist, it will be created and started.
306
- func (m * MultiStateMachineManager ) RemoveStateSub (assetSpec asset.Specifier ,
304
+ func (m * Manager ) RemoveStateSub (assetSpec asset.Specifier ,
307
305
sub StateSub ) error {
308
306
309
307
sm , err := m .fetchStateMachine (assetSpec )
@@ -331,7 +329,7 @@ type FetchCommitmentResp struct {
331
329
}
332
330
333
331
// FetchCommitment fetches the supply commitment for the given asset specifier.
334
- func (m * MultiStateMachineManager ) FetchCommitment (ctx context.Context ,
332
+ func (m * Manager ) FetchCommitment (ctx context.Context ,
335
333
assetSpec asset.Specifier ) (fn.Option [FetchCommitmentResp ], error ) {
336
334
337
335
var zero fn.Option [FetchCommitmentResp ]
@@ -379,7 +377,7 @@ func (m *MultiStateMachineManager) FetchCommitment(ctx context.Context,
379
377
380
378
// FetchSupplyLeavesByHeight returns the set of supply leaves for the given
381
379
// asset specifier within the specified height range.
382
- func (m * MultiStateMachineManager ) FetchSupplyLeavesByHeight (
380
+ func (m * Manager ) FetchSupplyLeavesByHeight (
383
381
ctx context.Context , assetSpec asset.Specifier , startHeight ,
384
382
endHeight uint32 ) (SupplyLeaves , error ) {
385
383
0 commit comments