Skip to content

Commit

Permalink
Remove state comparison in EvaluateActionsGradually
Browse files Browse the repository at this point in the history
  • Loading branch information
longfin committed May 15, 2019
1 parent 8b7598f commit a693780
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ 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 produce next states
without comparison even if states are not changed.

### Bug fixes

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

0 comments on commit a693780

Please sign in to comment.