Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple coord package from addressing #903

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion v2/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func NewBackendPublicKey(ds ds.TxnDatastore, cfg *RecordBackendConfig) (be *Reco
// The values returned from [ProvidersBackend.Fetch] will be of type
// [*providerSet] (unexported). The cfg parameter can be nil, in which case the
// [DefaultProviderBackendConfig] will be used.
func NewBackendProvider(pstore peerstore.Peerstore, dstore ds.Batching, cfg *ProvidersBackendConfig) (be *ProvidersBackend, err error) {
func NewBackendProvider(pstore peerstore.Peerstore, dstore ds.Datastore, cfg *ProvidersBackendConfig) (be *ProvidersBackend, err error) {
if cfg == nil {
if cfg, err = DefaultProviderBackendConfig(); err != nil {
return nil, fmt.Errorf("default provider backend config: %w", err)
Expand Down
7 changes: 4 additions & 3 deletions v2/backend_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,15 @@ func (p *ProvidersBackend) StartGarbageCollection() {
p.gcCancel = cancel
p.gcDone = make(chan struct{})

p.log.Info("Provider backend's started garbage collection schedule")
// init ticker outside the goroutine to prevent race condition with
// clock mock in garbage collection test.
ticker := p.cfg.clk.Ticker(p.cfg.GCInterval)

go func() {
defer close(p.gcDone)

ticker := p.cfg.clk.Ticker(p.cfg.GCInterval)
defer ticker.Stop()

p.log.Info("Provider backend started garbage collection schedule")
for {
select {
case <-ctx.Done():
Expand Down
5 changes: 3 additions & 2 deletions v2/backend_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/benbjohnson/clock"
ds "github.com/ipfs/go-datastore"
syncds "github.com/ipfs/go-datastore/sync"
"github.com/libp2p/go-libp2p"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -22,7 +21,9 @@ func newBackendProvider(t testing.TB, cfg *ProvidersBackendConfig) *ProvidersBac
h, err := libp2p.New(libp2p.NoListenAddrs)
require.NoError(t, err)

dstore := syncds.MutexWrap(ds.NewMapDatastore())
dstore, err := InMemoryDatastore()
require.NoError(t, err)

t.Cleanup(func() {
if err = dstore.Close(); err != nil {
t.Logf("closing datastore: %s", err)
Expand Down
39 changes: 0 additions & 39 deletions v2/coord/conversion.go

This file was deleted.

Loading
Loading