Skip to content

Commit

Permalink
feat: show bitswap stat
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Jun 17, 2019
1 parent c0a9ae5 commit 65cbe63
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
16 changes: 16 additions & 0 deletions IpfsCli/Commands/BitswapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Ipfs.Cli
[Subcommand("wantlist", typeof(BitswapWantListCommand))]
[Subcommand("unwant", typeof(BitswapUnwantCommand))]
[Subcommand("ledger", typeof(BitswapLedgerCommand))]
[Subcommand("stat", typeof(BitswapStatCommand))]
class BitswapCommand : CommandBase
{
public Program Parent { get; set; }
Expand Down Expand Up @@ -75,4 +76,19 @@ protected override async Task<int> OnExecute(CommandLineApplication app)
return Program.Output(app, ledger, null);
}
}

[Command(Description = "Show bitswap information")]
class BitswapStatCommand : CommandBase
{
BitswapCommand Parent { get; set; }

protected override async Task<int> OnExecute(CommandLineApplication app)
{
var Program = Parent.Parent;

var stats = await Program.CoreApi.Stats.BitswapAsync();
return Program.Output(app, stats, null);
}
}

}
2 changes: 2 additions & 0 deletions IpfsServer/HttpApi/V0/BitswapController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,7 @@ public async Task<BitswapLedgerDto> Ledger(string arg)
Value = ledger.DebtRatio
};
}

// "bitswap/stat" is handled by the StatsController.
}
}
2 changes: 1 addition & 1 deletion IpfsServer/HttpApi/V0/StatsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Task<BandwidthData> Bandwidth()
/// <summary>
/// Get bitswap information.
/// </summary>
[HttpGet, HttpPost, Route("stats/bitswap")]
[HttpGet, HttpPost, Route("stats/bitswap"), Route("bitswap/stat")]
public async Task<StatsBitswapDto> Bitswap()
{
Response.Headers.Add("X-Chunked-Output", "1");
Expand Down

0 comments on commit 65cbe63

Please sign in to comment.