-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0996705
commit f5f81ba
Showing
5 changed files
with
85 additions
and
1 deletion.
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,47 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Ipfs.CoreApi; | ||
using System.IO; | ||
|
||
namespace Ipfs.Http | ||
{ | ||
|
||
class BlockRepositoryApi : IBlockRepositoryApi | ||
{ | ||
IpfsClient ipfs; | ||
|
||
internal BlockRepositoryApi(IpfsClient ipfs) | ||
{ | ||
this.ipfs = ipfs; | ||
} | ||
|
||
public async Task RemoveGarbageAsync(CancellationToken cancel = default(CancellationToken)) | ||
{ | ||
await ipfs.DoCommandAsync("repo/gc", cancel); | ||
} | ||
|
||
public Task<RepositoryData> StatisticsAsync(CancellationToken cancel = default(CancellationToken)) | ||
{ | ||
return ipfs.DoCommandAsync<RepositoryData>("repo/stat", cancel); | ||
} | ||
|
||
public async Task VerifyAsync(CancellationToken cancel = default(CancellationToken)) | ||
{ | ||
await ipfs.DoCommandAsync("repo/verify", cancel); | ||
} | ||
|
||
public async Task<string> VersionAsync(CancellationToken cancel = default(CancellationToken)) | ||
{ | ||
var json = await ipfs.DoCommandAsync("repo/version", cancel); | ||
var info = JObject.Parse(json); | ||
return (string)info["Version"]; | ||
} | ||
} | ||
} |
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,32 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Ipfs.Http | ||
{ | ||
|
||
[TestClass] | ||
public class BlockRepositoryTest | ||
{ | ||
|
||
[TestMethod] | ||
public async Task Stats() | ||
{ | ||
var ipfs = TestFixture.Ipfs; | ||
var stats = await ipfs.BlockRepository.StatisticsAsync(); | ||
Assert.IsNotNull(stats); | ||
} | ||
|
||
[TestMethod] | ||
public async Task Version() | ||
{ | ||
var ipfs = TestFixture.Ipfs; | ||
var version = await ipfs.BlockRepository.VersionAsync(); | ||
Assert.IsFalse(string.IsNullOrWhiteSpace(version)); | ||
} | ||
|
||
} | ||
} |