Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove state comparison in EvaluateActionsGradually #241

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ To be released.
[[#228], [#234]]
- `Swarm.StartAsync()` now does not call `Swarm.StopAsync()` anymore,
therefore `Swarm.StopAsync()` should be explicitly called. [[#236]]
- `Transaction<T>.EvaluateActionsGradually()` became to record
`IAccountStateDelta.SetState()` calls even if its argument is the same
to the previous state. [[#241]]

### Bug fixes

Expand Down Expand Up @@ -147,6 +150,7 @@ To be released.
[#234]: https://github.com/planetarium/libplanet/pull/234
[#236]: https://github.com/planetarium/libplanet/pull/236
[#240]: https://github.com/planetarium/libplanet/pull/240
[#241]: https://github.com/planetarium/libplanet/pull/241


Version 0.2.2
Expand Down
1 change: 0 additions & 1 deletion Libplanet.Tests/Action/AccountStateDeltaImplTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public void GetSetState()
IAccountStateDelta c = b.SetState(_addr[0], "a");
Assert.Equal("a", c.GetState(_addr[0]));
Assert.Equal("z", b.GetState(_addr[0]));
Assert.Empty(c.UpdatedAddresses);
Assert.Empty(init.UpdatedAddresses);
}

Expand Down
14 changes: 1 addition & 13 deletions Libplanet/Action/AccountStateDeltaImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,9 @@ IAccountStateDelta IAccountStateDelta.SetState(
object state
)
{
IImmutableDictionary<Address, object> newState =
_updatedStates.SetItem(address, state);
foreach (Address addr in newState.Keys)
{
object epochState = _accountStateGetter(addr);
if (ReferenceEquals(epochState, state) ||
Equals(epochState, state))
{
newState = newState.Remove(addr);
}
}

return new AccountStateDeltaImpl(_accountStateGetter)
{
_updatedStates = newState,
_updatedStates = _updatedStates.SetItem(address, state),
};
}
}
Expand Down