-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 7746_update_jwt_path
- Loading branch information
Showing
79 changed files
with
562 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Nethermind/Nethermind.Core.Test/CachedBlockTreeBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using System; | ||
using Nethermind.Blockchain; | ||
using Nethermind.Core.Test.Builders; | ||
using Nethermind.Db; | ||
using NonBlocking; | ||
|
||
namespace Nethermind.Core.Test; | ||
|
||
public class CachedBlockTreeBuilder | ||
{ | ||
private static ConcurrentDictionary<string, CachedDb> _cachedDbs = new(); | ||
private record CachedDb( | ||
MemDb blocksDb, | ||
MemDb metadataDb, | ||
MemDb headersDb, | ||
MemDb blockNumbersDb, | ||
MemDb blockInfo | ||
); | ||
|
||
public static IBlockTree BuildCached(string key, Func<BlockTreeBuilder> blockTreeBuilderFactory) | ||
{ | ||
if (_cachedDbs.TryGetValue(key, out CachedDb? db)) | ||
{ | ||
return Build.A.BlockTree() | ||
.WithBlocksDb(MemDb.CopyFrom(db.blocksDb)) | ||
.WithMetadataDb(MemDb.CopyFrom(db.metadataDb)) | ||
.WithHeadersDb(MemDb.CopyFrom(db.headersDb)) | ||
.WithBlocksNumberDb(MemDb.CopyFrom(db.blockNumbersDb)) | ||
.WithBlockInfoDb(MemDb.CopyFrom(db.blockInfo)) | ||
.TestObject; | ||
} | ||
else | ||
{ | ||
BlockTreeBuilder builder = blockTreeBuilderFactory(); | ||
CachedDb cachedValue = new CachedDb( | ||
MemDb.CopyFrom(builder.BlocksDb), | ||
MemDb.CopyFrom(builder.MetadataDb), | ||
MemDb.CopyFrom(builder.HeadersDb), | ||
MemDb.CopyFrom(builder.BlockNumbersDb), | ||
MemDb.CopyFrom(builder.BlockInfoDb) | ||
); | ||
_cachedDbs.GetOrAdd(key, cachedValue); | ||
|
||
return builder.TestObject; | ||
} | ||
} | ||
|
||
public static IBlockTree OfLength(int length) | ||
{ | ||
return BuildCached($"{nameof(CachedBlockTreeBuilder)}-{length}", () => Build.A.BlockTree().OfChainLength(length)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.