use a sync.Once for manifest loading to avoid interference from parallel test runs
This commit is contained in:
parent
5e3112fa95
commit
17d72f02a1
@ -2,6 +2,7 @@ package actors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -19,12 +20,23 @@ var ManifestCids map[Version]cid.Cid = map[Version]cid.Cid{
|
||||
var manifests map[Version]*manifest.Manifest
|
||||
var actorMeta map[cid.Cid]actorEntry
|
||||
|
||||
var (
|
||||
loadOnce sync.Once
|
||||
loadError error
|
||||
)
|
||||
|
||||
type actorEntry struct {
|
||||
name string
|
||||
version Version
|
||||
}
|
||||
|
||||
func LoadManifests(ctx context.Context, store cbor.IpldStore) error {
|
||||
// tests may invoke this concurrently, so we wrap it in a sync.Once
|
||||
loadOnce.Do(func() { loadError = loadManifests(ctx, store) })
|
||||
return loadError
|
||||
}
|
||||
|
||||
func loadManifests(ctx context.Context, store cbor.IpldStore) error {
|
||||
adtStore := adt.WrapStore(ctx, store)
|
||||
|
||||
manifests = make(map[Version]*manifest.Manifest)
|
||||
|
Loading…
Reference in New Issue
Block a user