-
-
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.
added support for an experimental batched provider system
The batched provider system is enabled when the experimental AcceleratedDHTClient is enabled There is also an `ipfs stats provide` command which gives stats about the providing/reproviding system when the batched provider system is enabled
- Loading branch information
1 parent
3556ad2
commit dbdee7f
Showing
6 changed files
with
113 additions
and
9 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
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 the experimental DHT client 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
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