Skip to content

Commit

Permalink
Add concurrent reads
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Nov 13, 2024
1 parent 75f94bf commit e485bd0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions vms/platformvm/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion vms/platformvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (vm *VM) Initialize(
mempool,
txExecutorBackend.Config.PartialSyncPrimaryNetwork,
appSender,
&chainCtx.Lock,
chainCtx.Lock.RLocker(),
vm.state,
chainCtx.WarpSigner,
registerer,
Expand Down

0 comments on commit e485bd0

Please sign in to comment.