@@ -241,7 +241,7 @@ type manager struct {
241
241
unblockChainCreatorCh chan struct {}
242
242
chainCreatorShutdownCh chan struct {}
243
243
244
- subnetsLock sync.Mutex
244
+ subnetsLock sync.RWMutex
245
245
// Key: Subnet's ID
246
246
// Value: Subnet description
247
247
subnets map [ids.ID ]subnets.Subnet
@@ -322,9 +322,9 @@ func (m *manager) createChain(chainParams ChainParameters) {
322
322
zap .Stringer ("vmID" , chainParams .VMID ),
323
323
)
324
324
325
- m .subnetsLock .Lock ()
325
+ m .subnetsLock .RLock ()
326
326
sb := m .subnets [chainParams .SubnetID ]
327
- m .subnetsLock .Unlock ()
327
+ m .subnetsLock .RUnlock ()
328
328
329
329
// Note: buildChain builds all chain's relevant objects (notably engine and handler)
330
330
// but does not start their operations. Starting of the handler (which could potentially
@@ -1285,8 +1285,8 @@ func (m *manager) IsBootstrapped(id ids.ID) bool {
1285
1285
}
1286
1286
1287
1287
func (m * manager ) subnetsNotBootstrapped () []ids.ID {
1288
- m .subnetsLock .Lock ()
1289
- defer m .subnetsLock .Unlock ()
1288
+ m .subnetsLock .RLock ()
1289
+ defer m .subnetsLock .RUnlock ()
1290
1290
1291
1291
subnetsBootstrapping := make ([]ids.ID , 0 , len (m .subnets ))
1292
1292
for subnetID , subnet := range m .subnets {
@@ -1323,8 +1323,8 @@ func (m *manager) StartChainCreator(platformParams ChainParameters) error {
1323
1323
return errNoPlatformSubnetConfig
1324
1324
}
1325
1325
1326
- m .subnetsLock .Lock ()
1327
1326
sb := subnets .New (m .NodeID , sbConfig )
1327
+ m .subnetsLock .Lock ()
1328
1328
m .subnets [platformParams .SubnetID ] = sb
1329
1329
sb .AddChain (platformParams .ID )
1330
1330
m .subnetsLock .Unlock ()
0 commit comments