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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
"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 manifests map[Version]*manifest.Manifest
|
||||||
var actorMeta map[cid.Cid]actorEntry
|
var actorMeta map[cid.Cid]actorEntry
|
||||||
|
|
||||||
|
var (
|
||||||
|
loadOnce sync.Once
|
||||||
|
loadError error
|
||||||
|
)
|
||||||
|
|
||||||
type actorEntry struct {
|
type actorEntry struct {
|
||||||
name string
|
name string
|
||||||
version Version
|
version Version
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadManifests(ctx context.Context, store cbor.IpldStore) error {
|
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)
|
adtStore := adt.WrapStore(ctx, store)
|
||||||
|
|
||||||
manifests = make(map[Version]*manifest.Manifest)
|
manifests = make(map[Version]*manifest.Manifest)
|
||||||
|
Loading…
Reference in New Issue
Block a user