Skip to content

Commit

Permalink
fix: Fix AccountMetrics to initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
OnedgeLee committed Nov 24, 2023
1 parent 6708233 commit c304271
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ To be released.
- (Libplanet.Net) `GossipConsensusMessageCommunicator` now filters
`ConsensusVoteMsg` which height is different from latest `Context`.
[[#3519]]
- (Libplanet.Action) Fixed a bug where initialization of `AccountMetrics`
is absent. [[#3521]]

[#3519]: https://github.com/planetarium/libplanet/pull/3519
[#3521]: https://github.com/planetarium/libplanet/pull/3521


Version 3.8.0
Expand Down
6 changes: 6 additions & 0 deletions Libplanet.Action/AccountMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ public static class AccountMetrics
{
public static readonly AsyncLocal<Stopwatch> GetStateTimer = new AsyncLocal<Stopwatch>();
public static readonly AsyncLocal<int> GetStateCount = new AsyncLocal<int>();

public static void Initialize()
{
GetStateTimer.Value = new Stopwatch();
GetStateCount.Value = 0;
}
}
}
1 change: 1 addition & 0 deletions Libplanet.Action/ActionEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ IActionContext CreateActionContext(IAccount newPrevState)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
AccountMetrics.Initialize();
state = feeCollector.Mortgage(state);
context = CreateActionContext(state);
feeCollector = feeCollector.Next(context);
Expand Down

0 comments on commit c304271

Please sign in to comment.