Skip to content

Commit

Permalink
feat:ipfs check
Browse files Browse the repository at this point in the history
  • Loading branch information
yanzq committed Oct 30, 2023
1 parent 279722a commit 3566764
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions dag/pool/ipfs/client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ipfs

import (
"context"
"github.com/ipfs/boxo/exchange/offline"
"github.com/ipfs/go-blockservice"
blockstore "github.com/ipfs/go-ipfs-blockstore"
Expand All @@ -22,11 +23,13 @@ func NewBlockService(blkstore blockstore.Blockstore) blockservice.BlockService {

// NewPoolClient new a dagPoolClient
func NewPoolClient(api *rpc.HttpApi, enablePin bool) (*PoolClient, error) {
return &PoolClient{
pool := &PoolClient{
api: api,
addr: "",
enablePin: enablePin,
}, nil
}
_, err := pool.api.Swarm().ListenAddrs(context.Background())
return pool, err
}
func (i *PoolClient) Close() {}
func (i *PoolClient) Block() *BlockAPI {
Expand All @@ -35,3 +38,10 @@ func (i *PoolClient) Block() *BlockAPI {
func (i *PoolClient) Store() *Store {
return (*Store)(i)
}
func (i *PoolClient) Health(ctx context.Context) bool {
_, err := i.api.Swarm().ListenAddrs(ctx)
if err != nil {
log.Error("IPFS is not healthy %v", err)
}
return err == nil
}

0 comments on commit 3566764

Please sign in to comment.