Skip to content

Commit

Permalink
fix(IpfsEngine): auto migrate the repo when engine is started
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Aug 5, 2019
1 parent aeea5ce commit a843b95
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/IpfsEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Ipfs.CoreApi;
using Ipfs.Engine.CoreApi;
using Ipfs.Engine.Cryptography;
using Ipfs.Engine.Migration;
using PeerTalk;
using System.Reflection;
using PeerTalk.Discovery;
Expand Down Expand Up @@ -117,6 +118,8 @@ void Init()
Stats = new StatsApi(this);
Swarm = new SwarmApi(this);

MigrationManager = new MigrationManager(this);

// Async properties
LocalPeer = new AsyncLazy<Peer>(async () =>
{
Expand Down Expand Up @@ -210,6 +213,11 @@ void Init()
/// </summary>
public IpfsEngineOptions Options { get; set; } = new IpfsEngineOptions();

/// <summary>
/// Manages the version of the repository.
/// </summary>
public MigrationManager MigrationManager { get; set; }

/// <inheritdoc />
public IBitswapApi Bitswap { get; set; }

Expand Down Expand Up @@ -359,6 +367,10 @@ public async Task StartAsync()
throw new Exception("IPFS engine is already started.");
}

// Repository must be at the correct version.
await MigrationManager.MirgrateToVersionAsync(MigrationManager.LatestVersion)
.ConfigureAwait(false);

var localPeer = await LocalPeer.ConfigureAwait(false);
log.Debug("starting " + localPeer.Id);

Expand Down

0 comments on commit a843b95

Please sign in to comment.