Skip to content

Commit

Permalink
Merge pull request #144 from richardschneider/peer-manager
Browse files Browse the repository at this point in the history
Peer manager
  • Loading branch information
richardschneider authored Aug 22, 2019
2 parents c9d16d0 + ae3564b commit 0319539
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions IpfsCli/IpfsCli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
<IsShippingPackage>true</IsShippingPackage>
<AllowedReferenceRelatedFileExtensions Condition=" '$(Configuration)' == 'Release' ">
<AllowedReferenceRelatedFileExtensions Condition=" '$(Configuration)' == 'Release' ">
<!-- Prevent default XML and PDB files copied to output in RELEASE. Only *.allowedextension files will be included, which doesn't exist in my case. -->
*.pdb;
*.xml
Expand All @@ -37,7 +37,7 @@

<ItemGroup>
<PackageReference Include="Common.Logging" Version="3.4.1" />
<PackageReference Include="Ipfs.Http.Client" Version="0.31.0" />
<PackageReference Include="Ipfs.Http.Client" Version="0.32.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
Expand Down
2 changes: 1 addition & 1 deletion IpfsServer/HttpApi/V0/SwamController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ConnectedPeerDto(Peer peer)
{
Peer = peer.Id.ToString();
Addr = peer.ConnectedAddress?.WithoutPeerId().ToString();
Latency = peer.Latency == null ? string.Empty : Duration.Stringify(peer.Latency.Value, string.Empty);
Latency = peer.Latency == null ? "n/a" : Duration.Stringify(peer.Latency.Value, string.Empty);
}
}

Expand Down
2 changes: 1 addition & 1 deletion IpfsServer/IpfsServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

</PropertyGroup>
<ItemGroup>
<PackageReference Include="Ipfs.Core" Version="0.53.1" />
<PackageReference Include="Ipfs.Core" Version="0.54.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/CoreApi/GenericApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GenericApi(IpfsEngine ipfs)
return await ipfs.Dht.FindPeerAsync(peer, cancel).ConfigureAwait(false);
}

public async Task<string> ResolveAsync(string name, bool recursive = false, CancellationToken cancel = default(CancellationToken))
public async Task<string> ResolveAsync(string name, bool recursive = true, CancellationToken cancel = default(CancellationToken))
{
var path = name;
if (path.StartsWith("/ipns/"))
Expand Down
7 changes: 1 addition & 6 deletions src/CoreApi/SwarmApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,7 @@ public SwarmApi(IpfsEngine ipfs)
var strings = addrs.Select(a => a.ToString());
await ipfs.Config.SetAsync("Swarm.AddrFilters", JToken.FromObject(strings), cancel).ConfigureAwait(false);

var bag = new WhiteList<MultiAddress>();
foreach (var a in addrs)
{
bag.Add(a);
}
(await ipfs.SwarmService.ConfigureAwait(false)).WhiteList = bag;
(await ipfs.SwarmService.ConfigureAwait(false)).WhiteList.Remove(address);

return address;
}
Expand Down
7 changes: 7 additions & 0 deletions src/IpfsEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ await MigrationManager.MirgrateToVersionAsync(MigrationManager.LatestVersion)
});
await swarm.StartAsync().ConfigureAwait(false);

var peerManager = new PeerManager { Swarm = swarm };
await peerManager.StartAsync().ConfigureAwait(false);
stopTasks.Add(async () =>
{
await peerManager.StopAsync().ConfigureAwait(false);
});

// Start the primary services.
var tasks = new List<Func<Task>>
{
Expand Down
4 changes: 2 additions & 2 deletions src/IpfsEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ipfs.Core" Version="0.53.1" />
<PackageReference Include="Ipfs.Core" Version="0.54.0" />
<PackageReference Include="Makaretu.Dns.Unicast" Version="0.11.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.0.0" />
<PackageReference Include="PeerTalk" Version="0.15.0" />
<PackageReference Include="PeerTalk" Version="0.16.0" />
<PackageReference Include="PeterO.Cbor" Version="3.1.0" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.5" />
<PackageReference Include="protobuf-net" Version="2.4.0" />
Expand Down
2 changes: 1 addition & 1 deletion test/CoreApi/GenericApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task Mars_Info()
var marsAddr = $"/ip6/::1/p2p/{marsId}";
var ipfs = TestFixture.Ipfs;
var swarm = await ipfs.SwarmService;
var mars = await swarm.RegisterPeerAsync(marsAddr);
var mars = swarm.RegisterPeerAddress(marsAddr);

var peer = await ipfs.Generic.IdAsync(marsId);
Assert.AreEqual(mars.Id, peer.Id);
Expand Down

0 comments on commit 0319539

Please sign in to comment.