Skip to content

Commit

Permalink
Add comments; Check ctx.Err(); Move import
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Michael Avila <davidmichaelavila@gmail.com>
  • Loading branch information
michaelavila committed Mar 20, 2019
1 parent 09cc62e commit 019af75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"context"
"errors"
"fmt"
"github.com/ipfs/go-ipfs/provider"
"io"
"io/ioutil"
"os"
Expand All @@ -29,6 +28,7 @@ import (
ipnsrp "github.com/ipfs/go-ipfs/namesys/republisher"
p2p "github.com/ipfs/go-ipfs/p2p"
pin "github.com/ipfs/go-ipfs/pin"
provider "github.com/ipfs/go-ipfs/provider"
repo "github.com/ipfs/go-ipfs/repo"

bitswap "github.com/ipfs/go-bitswap"
Expand Down
9 changes: 5 additions & 4 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ package provider

import (
"context"

cid "github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log"
routing "github.com/libp2p/go-libp2p-routing"
"github.com/libp2p/go-libp2p-routing"
)

var log = logging.Logger("provider")
Expand All @@ -17,7 +16,9 @@ const provideOutgoingWorkerLimit = 8

// Provider announces blocks to the network
type Provider interface {
// Run is used to begin processing the provider work
Run()
// Provide takes a cid and makes an attempt to announce it to the network
Provide(cid.Cid) error
}

Expand Down Expand Up @@ -53,7 +54,7 @@ func (p *provider) Provide(root cid.Cid) error {
func (p *provider) handleAnnouncements() {
for workers := 0; workers < provideOutgoingWorkerLimit; workers++ {
go func() {
for {
for p.ctx.Err() == nil {
select {
case <-p.ctx.Done():
return
Expand Down

0 comments on commit 019af75

Please sign in to comment.