-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8061 from ipfs/feat/experimental-dht-client
Added support for an experimental DHT client and provider system via the Experiments.AcceleratedDHTClient config option
- Loading branch information
Showing
14 changed files
with
358 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package commands | ||
|
||
import ( | ||
"fmt" | ||
|
||
cmds "github.com/ipfs/go-ipfs-cmds" | ||
"github.com/ipfs/go-ipfs/core/commands/cmdenv" | ||
|
||
"github.com/ipfs/go-ipfs-provider/batched" | ||
) | ||
|
||
var statProvideCmd = &cmds.Command{ | ||
Helptext: cmds.HelpText{ | ||
Tagline: "Returns statistics about the node's (re)provider system.", | ||
ShortDescription: ` | ||
Returns statistics about the content the node is advertising. | ||
This interface is not stable and may change from release to release. | ||
`, | ||
}, | ||
Arguments: []cmds.Argument{}, | ||
Options: []cmds.Option{}, | ||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { | ||
nd, err := cmdenv.GetNode(env) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !nd.IsOnline { | ||
return ErrNotOnline | ||
} | ||
|
||
sys, ok := nd.Provider.(*batched.BatchProvidingSystem) | ||
if !ok { | ||
return fmt.Errorf("can only return stats if Experimental.AcceleratedDHTClient is enabled") | ||
} | ||
|
||
stats, err := sys.Stat(req.Context) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := res.Emit(stats); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
Encoders: cmds.EncoderMap{}, | ||
Type: batched.BatchedProviderStats{}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.