forked from NethermindEth/nethermind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trie RlpStreams as structs (NethermindEth#6584)
- Loading branch information
Showing
7 changed files
with
537 additions
and
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using Nethermind.Core; | ||
using Nethermind.Core.Buffers; | ||
|
||
namespace Nethermind.Serialization.Rlp | ||
{ | ||
public class RlpFactory | ||
{ | ||
public long MemorySize => MemorySizes.SmallObjectOverhead | ||
+ MemorySizes.Align(MemorySizes.ArrayOverhead + _data.Length) | ||
+ MemorySizes.Align(sizeof(int)); | ||
|
||
private readonly CappedArray<byte> _data; | ||
|
||
public ref readonly CappedArray<byte> Data => ref _data; | ||
|
||
public RlpFactory(in CappedArray<byte> data) | ||
{ | ||
_data = data; | ||
} | ||
|
||
public ValueRlpStream GetRlpStream() | ||
{ | ||
return new(in _data); | ||
} | ||
} | ||
} |
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.