Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions chains/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ type manager struct {
unblockChainCreatorCh chan struct{}
chainCreatorShutdownCh chan struct{}

subnetsLock sync.Mutex
subnetsLock sync.RWMutex
// Key: Subnet's ID
// Value: Subnet description
subnets map[ids.ID]subnets.Subnet
Expand Down Expand Up @@ -322,9 +322,9 @@ func (m *manager) createChain(chainParams ChainParameters) {
zap.Stringer("vmID", chainParams.VMID),
)

m.subnetsLock.Lock()
m.subnetsLock.RLock()
sb := m.subnets[chainParams.SubnetID]
m.subnetsLock.Unlock()
m.subnetsLock.RUnlock()

// Note: buildChain builds all chain's relevant objects (notably engine and handler)
// but does not start their operations. Starting of the handler (which could potentially
Expand Down Expand Up @@ -1285,8 +1285,8 @@ func (m *manager) IsBootstrapped(id ids.ID) bool {
}

func (m *manager) subnetsNotBootstrapped() []ids.ID {
m.subnetsLock.Lock()
defer m.subnetsLock.Unlock()
m.subnetsLock.RLock()
defer m.subnetsLock.RUnlock()

subnetsBootstrapping := make([]ids.ID, 0, len(m.subnets))
for subnetID, subnet := range m.subnets {
Expand Down Expand Up @@ -1323,8 +1323,8 @@ func (m *manager) StartChainCreator(platformParams ChainParameters) error {
return errNoPlatformSubnetConfig
}

m.subnetsLock.Lock()
sb := subnets.New(m.NodeID, sbConfig)
m.subnetsLock.Lock()
m.subnets[platformParams.SubnetID] = sb
sb.AddChain(platformParams.ID)
m.subnetsLock.Unlock()
Expand Down