From e485bd0d40c032c61343fa2dea9cec78a83285d8 Mon Sep 17 00:00:00 2001 From: Stephen Buttolph Date: Tue, 12 Nov 2024 20:06:46 -0500 Subject: [PATCH] Add concurrent reads --- vms/platformvm/state/state.go | 4 ++++ vms/platformvm/vm.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/vms/platformvm/state/state.go b/vms/platformvm/state/state.go index d2dfd34e47a8..58afa8498ddd 100644 --- a/vms/platformvm/state/state.go +++ b/vms/platformvm/state/state.go @@ -816,6 +816,7 @@ func (s *state) GetExpiryIterator() (iterator.Iterator[ExpiryEntry], error) { ), nil } +// HasExpiry allows for concurrent reads. func (s *state) HasExpiry(entry ExpiryEntry) (bool, error) { if has, modified := s.expiryDiff.modified[entry]; modified { return has, nil @@ -859,6 +860,7 @@ func (s *state) WeightOfSubnetOnlyValidators(subnetID ids.ID) (uint64, error) { return weight, nil } +// GetSubnetOnlyValidator allows for concurrent reads. func (s *state) GetSubnetOnlyValidator(validationID ids.ID) (SubnetOnlyValidator, error) { if sov, modified := s.sovDiff.modified[validationID]; modified { if sov.isDeleted() { @@ -1047,6 +1049,7 @@ func (s *state) SetSubnetOwner(subnetID ids.ID, owner fx.Owner) { s.subnetOwners[subnetID] = owner } +// GetSubnetConversion allows for concurrent reads. func (s *state) GetSubnetConversion(subnetID ids.ID) (SubnetConversion, error) { if c, ok := s.subnetConversions[subnetID]; ok { return c, nil @@ -1267,6 +1270,7 @@ func (s *state) GetEtnaHeight() (uint64, error) { return database.GetUInt64(s.singletonDB, EtnaHeightKey) } +// GetTimestamp allows for concurrent reads. func (s *state) GetTimestamp() time.Time { return s.timestamp } diff --git a/vms/platformvm/vm.go b/vms/platformvm/vm.go index 09026085e229..90540203e8d9 100644 --- a/vms/platformvm/vm.go +++ b/vms/platformvm/vm.go @@ -193,7 +193,7 @@ func (vm *VM) Initialize( mempool, txExecutorBackend.Config.PartialSyncPrimaryNetwork, appSender, - &chainCtx.Lock, + chainCtx.Lock.RLocker(), vm.state, chainCtx.WarpSigner, registerer,