Skip to content

Commit

Permalink
Remove pruning from Swarm
Browse files Browse the repository at this point in the history
  • Loading branch information
earlbread committed Feb 20, 2020
1 parent 247d1ec commit 8a24970
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
10 changes: 0 additions & 10 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ To be released.

### Backward-incompatible API changes

- The existing `Swarm<T>.PreloadAsync(TimeSpan?, IProgress<PreloadState>,
IImmutableSet<Address>, EventHandler<PreloadBlockDownloadFailEventArgs>,
CancellationToken)` method has been replaced by
`Swarm<T>.PreloadAsync(TimeSpan?, IProgress<PreloadState>, IImmutableSet<Address>,
EventHandler<PreloadBlockDownloadFailEventArgs>, long, CancellationToken)`
method where `long`-typed `thickness` indicates thickness of recent states.
[[#790]]

### Backward-incompatible network protocol changes

- `BaseStore` class became to implement `IDisposable`. [[#789]]
Expand All @@ -32,8 +24,6 @@ To be released.

### Behavioral changes

- `Swarm<T>.PreloadAsync()` became to prune states until its parameter
`thickness` if any trusted peers were given. [[#790]]
- `BlockChain.MineBlock()` method became to ignore transactions having
lower nonce than the expected nonce in the chain. [[#791]]

Expand Down
6 changes: 2 additions & 4 deletions Libplanet.Tests/Net/SwarmTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2128,8 +2128,7 @@ public async Task PreloadWithDifferenctFindNextStatesChunkSize()

await swarm1.AddPeersAsync(new[] { swarm0.AsPeer }, null);
await swarm1.PreloadAsync(
trustedStateValidators: new[] { swarm0.Address }.ToImmutableHashSet(),
thickness: 20);
trustedStateValidators: new[] { swarm0.Address }.ToImmutableHashSet());

Assert.Equal(chain0.BlockHashes, chain1.BlockHashes);

Expand Down Expand Up @@ -2167,8 +2166,7 @@ await swarm1.PreloadAsync(

await swarm2.AddPeersAsync(new[] { swarm1.AsPeer }, null);
await swarm2.PreloadAsync(
trustedStateValidators: new[] { swarm1.Address }.ToImmutableHashSet(),
thickness: 20);
trustedStateValidators: new[] { swarm1.Address }.ToImmutableHashSet());

Assert.Equal(chain1.BlockHashes, chain2.BlockHashes);

Expand Down
11 changes: 1 addition & 10 deletions Libplanet/Net/Swarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ await StartAsync(
/// period of time. This can lead a game startup slow. If you want to omit rendering of
/// these actions in the behind blocks use <see cref=
/// "PreloadAsync(TimeSpan?, IProgress{PreloadState}, IImmutableSet{Address},
/// EventHandler{PreloadBlockDownloadFailEventArgs}, long, CancellationToken)"
/// EventHandler{PreloadBlockDownloadFailEventArgs}, CancellationToken)"
/// /> method too.</remarks>
public async Task StartAsync(
TimeSpan dialTimeout,
Expand Down Expand Up @@ -391,7 +391,6 @@ public string TraceTable()
/// <param name="blockDownloadFailed">
/// The <see cref="EventHandler" /> triggered when block downloading fails.
/// </param>
/// <param name="thickness">A thickness to leave state history.</param>
/// <param name="cancellationToken">
/// A cancellation token used to propagate notification that this
/// operation should be canceled.
Expand All @@ -408,7 +407,6 @@ public async Task PreloadAsync(
IProgress<PreloadState> progress = null,
IImmutableSet<Address> trustedStateValidators = null,
EventHandler<PreloadBlockDownloadFailEventArgs> blockDownloadFailed = null,
long thickness = 10,
CancellationToken cancellationToken = default(CancellationToken)
)
{
Expand Down Expand Up @@ -541,13 +539,6 @@ await SyncBehindsBlocksFromPeerAsync(
cancellationToken);
}

if (trustedStateValidators.Any() && height > thickness)
{
_store.PruneBlockStates(
workspace.Id,
workspace[height - thickness]);
}

complete = true;
}
finally
Expand Down

0 comments on commit 8a24970

Please sign in to comment.