File tree Expand file tree Collapse file tree 4 files changed +72
-1
lines changed Expand file tree Collapse file tree 4 files changed +72
-1
lines changed Original file line number Diff line number Diff line change 1+ using Common . Logging ;
2+ using Newtonsoft . Json ;
3+ using Newtonsoft . Json . Linq ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . IO ;
7+ using System . Linq ;
8+ using System . Text ;
9+ using System . Threading ;
10+ using System . Threading . Tasks ;
11+ using Ipfs . CoreApi ;
12+
13+ namespace Ipfs . Http
14+ {
15+
16+ class StatApi : IStatsApi
17+ {
18+ IpfsClient ipfs ;
19+
20+ internal StatApi ( IpfsClient ipfs )
21+ {
22+ this . ipfs = ipfs ;
23+ }
24+
25+ public Task < BandwidthData > BandwidthAsync ( CancellationToken cancel = default ( CancellationToken ) )
26+ {
27+ return ipfs . DoCommandAsync < BandwidthData > ( "stats/bw" , cancel ) ;
28+ }
29+
30+ public Task < BitswapData > BitswapAsync ( CancellationToken cancel = default ( CancellationToken ) )
31+ {
32+ return ipfs . DoCommandAsync < BitswapData > ( "stats/bitswap" , cancel ) ;
33+ }
34+
35+ public Task < RepositoryData > RepositoryAsync ( CancellationToken cancel = default ( CancellationToken ) )
36+ {
37+ return ipfs . DoCommandAsync < RepositoryData > ( "stats/repo" , cancel ) ;
38+ }
39+
40+
41+ }
42+ }
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ public IpfsClient()
7878 Generic = this ;
7979 Name = new NameApi ( this ) ;
8080 Dns = new DnsApi ( this ) ;
81+ Stats = new StatApi ( this ) ;
8182 }
8283
8384 /// <summary>
@@ -128,6 +129,9 @@ public IpfsClient(string host)
128129 /// <inheritdoc />
129130 public IDnsApi Dns { get ; private set ; }
130131
132+ /// <inheritdoc />
133+ public IStatsApi Stats { get ; private set ; }
134+
131135 /// <inheritdoc />
132136 public INameApi Name { get ; private set ; }
133137
Original file line number Diff line number Diff line change 2727 </PropertyGroup >
2828
2929 <ItemGroup >
30- <PackageReference Include =" Ipfs.Core" Version =" 0.35.2 " />
30+ <PackageReference Include =" Ipfs.Core" Version =" 0.38.0 " />
3131 <PackageReference Include =" Newtonsoft.Json" Version =" 11.0.2" />
3232 <PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'netstandard14'" />
3333 <PackageReference Include =" System.Net.Http" Version =" 4.3.3" Condition =" '$(TargetFramework)' == 'net45'" />
Original file line number Diff line number Diff line change 1+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
2+ using Newtonsoft . Json . Linq ;
3+ using System ;
4+ using System . Linq ;
5+ using System . Text ;
6+ using System . Threading . Tasks ;
7+
8+ namespace Ipfs . Http
9+ {
10+
11+ [ TestClass ]
12+ public class StatsApiTest
13+ {
14+
15+ [ TestMethod ]
16+ public async Task SmokeTest ( )
17+ {
18+ var ipfs = TestFixture . Ipfs ;
19+ var bandwidth = await ipfs . Stats . BandwidthAsync ( ) ;
20+ var bitswap = await ipfs . Stats . BitswapAsync ( ) ;
21+ var repository = await ipfs . Stats . RepositoryAsync ( ) ;
22+ }
23+
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments