diff --git a/dag/pool/ipfs/client.go b/dag/pool/ipfs/client.go index 08f6735..2307f78 100644 --- a/dag/pool/ipfs/client.go +++ b/dag/pool/ipfs/client.go @@ -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" @@ -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 { @@ -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 +}