Skip to content

Commit

Permalink
Log errors as warnings - better suited log level
Browse files Browse the repository at this point in the history
  • Loading branch information
hsanjuan committed Oct 3, 2023
1 parent 1815bc1 commit 362276c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions ipfs/blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (nbs *BlockService) Close() error {
// Gets a block unless CID has been blocked.
func (nbs *BlockService) GetBlock(ctx context.Context, c cid.Cid) (blocks.Block, error) {
if err := nbs.blocker.IsCidBlocked(c).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
return nil, err
}
return nbs.bs.GetBlock(ctx, c)
Expand All @@ -50,7 +50,7 @@ func (nbs *BlockService) GetBlocks(ctx context.Context, ks []cid.Cid) <-chan blo
var filtered []cid.Cid
for _, c := range ks {
if err := nbs.blocker.IsCidBlocked(c).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
logger.Warnf("GetBlocks dropped blocked block: %s", err)
} else {
filtered = append(filtered, c)
Expand All @@ -72,7 +72,7 @@ func (nbs *BlockService) Exchange() exchange.Interface {
// AddBlock adds a block unless the CID is blocked.
func (nbs *BlockService) AddBlock(ctx context.Context, o blocks.Block) error {
if err := nbs.blocker.IsCidBlocked(o.Cid()).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
return err
}
return nbs.bs.AddBlock(ctx, o)
Expand All @@ -83,7 +83,7 @@ func (nbs *BlockService) AddBlocks(ctx context.Context, bs []blocks.Block) error
var filtered []blocks.Block
for _, o := range bs {
if err := nbs.blocker.IsCidBlocked(o.Cid()).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
logger.Warnf("AddBlocks dropped blocked block: %s", err)
} else {
filtered = append(filtered, o)
Expand Down
4 changes: 2 additions & 2 deletions ipfs/namesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func WrapNameSystem(ns namesys.NameSystem, blocker *nopfs.Blocker) namesys.NameS
// Resolve resolves an IPNS name unless it is blocked.
func (ns *NameSystem) Resolve(ctx context.Context, name string, options ...opts.ResolveOpt) (path.Path, error) {
if err := ns.blocker.IsPathBlocked(path.FromString(name)).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
return "", err
}
return ns.ns.Resolve(ctx, name, options...)
Expand All @@ -41,7 +41,7 @@ func (ns *NameSystem) Resolve(ctx context.Context, name string, options ...opts.
func (ns *NameSystem) ResolveAsync(ctx context.Context, name string, options ...opts.ResolveOpt) <-chan namesys.Result {
status := ns.blocker.IsPathBlocked(path.FromString(name))
if err := status.ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
ch := make(chan namesys.Result, 1)
ch <- namesys.Result{
Path: status.Path,
Expand Down
6 changes: 3 additions & 3 deletions ipfs/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func WrapResolver(res resolver.Resolver, blocker *nopfs.Blocker) resolver.Resolv
// ResolveToLastNode checks if the given path is blocked before resolving.
func (res *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid.Cid, []string, error) {
if err := res.blocker.IsPathBlocked(fpath).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
return cid.Undef, nil, err
}
return res.resolver.ResolveToLastNode(ctx, fpath)
Expand All @@ -40,7 +40,7 @@ func (res *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (ci
// ResolvePath checks if the given path is blocked before resolving.
func (res *Resolver) ResolvePath(ctx context.Context, fpath path.Path) (ipld.Node, ipld.Link, error) {
if err := res.blocker.IsPathBlocked(fpath).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
return nil, nil, err
}
return res.resolver.ResolvePath(ctx, fpath)
Expand All @@ -49,7 +49,7 @@ func (res *Resolver) ResolvePath(ctx context.Context, fpath path.Path) (ipld.Nod
// ResolvePathComponents checks if the given path is blocked before resolving.
func (res *Resolver) ResolvePathComponents(ctx context.Context, fpath path.Path) ([]ipld.Node, error) {
if err := res.blocker.IsPathBlocked(fpath).ToError(); err != nil {
logger.Error(err.Response)
logger.Warn(err.Response)
return nil, err
}
return res.resolver.ResolvePathComponents(ctx, fpath)
Expand Down

0 comments on commit 362276c

Please sign in to comment.