Skip to content

Commit

Permalink
revert Transaction.cs only
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekM25 committed Jun 14, 2023
1 parent 42ba08b commit f2a9574
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 36 deletions.
67 changes: 33 additions & 34 deletions src/Nethermind/Nethermind.Core/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,64 +49,63 @@ public class Transaction
{
get
{
if (_hash is not null) return _hash;
Keccak? hash = _hash;
if (hash is not null) return hash;

lock (this)
if (_preHash.Length > 0)
{
if (_hash is not null) return _hash;
GenerateHash();
}

return _hash;

if (_preHash.Count > 0)
void GenerateHash()
{
_hash = Keccak.Compute(_preHash.Span);
if (MemoryMarshal.TryGetArray(_preHash, out ArraySegment<byte> rentedArray))
{
_hash = Keccak.Compute(_preHash.AsSpan());
ClearPreHashInternal();
ArrayPool<byte>.Shared.Return(rentedArray.Array!);
}
}

return _hash;
_preHash = default;
}
}
set
{
lock (this)
if (_preHash.Length > 0)
{
ClearPreHashInternal();
_hash = value;
if (MemoryMarshal.TryGetArray(_preHash, out ArraySegment<byte> rentedArray))
{
ArrayPool<byte>.Shared.Return(rentedArray.Array!);
}

_preHash = default;
}

_hash = value;
}
}

private ArraySegment<byte> _preHash;
private ReadOnlyMemory<byte> _preHash;
public void SetPreHash(ReadOnlySpan<byte> transactionSequence)
{
lock (this)
{
// Used to delay hash generation, as may be filtered as having too low gas etc
_hash = null;
// Used to delay hash generation, as may be filtered as having too low gas etc
_hash = null;

int size = transactionSequence.Length;
byte[] preHash = ArrayPool<byte>.Shared.Rent(size);
transactionSequence.CopyTo(preHash);
_preHash = new ArraySegment<byte>(preHash, 0, size);
}
int size = transactionSequence.Length;
byte[] preHash = ArrayPool<byte>.Shared.Rent(size);
transactionSequence.CopyTo(preHash);
_preHash = new ReadOnlyMemory<byte>(preHash, 0, size);
}

public void ClearPreHash()
{
if (_preHash.Count > 0)
if (MemoryMarshal.TryGetArray(_preHash, out ArraySegment<byte> rentedArray))
{
lock (this)
{
ClearPreHashInternal();
}
ArrayPool<byte>.Shared.Return(rentedArray.Array!);
}
}

private void ClearPreHashInternal()
{
if (_preHash.Count > 0)
{
ArrayPool<byte>.Shared.Return(_preHash.Array!);
_preHash = default;
}
_preHash = default;
}

public UInt256 Timestamp { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/Nethermind/Nethermind.GitBook/docs
Submodule docs updated 79 files
+ .gitbook/assets/image (10) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (10) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (10) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (10) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (10) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (10) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (4).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (5).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (4).png
+ .gitbook/assets/image (117) (2) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (5).png
+ .gitbook/assets/image (15) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (15) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (15) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (15) (3) (3) (3) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (157) (1) (3) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (157) (1) (3) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (157) (1) (3) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (157) (1) (3) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (18) (1) (1) (1) (1) (1) (1) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (18) (1) (1) (1) (1) (1) (1) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (18) (1) (1) (1) (1) (1) (1) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (18) (1) (1) (1) (1) (1) (1) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (18) (1) (1) (1) (1) (1) (1) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (18) (1) (1) (1) (1) (1) (1) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (18) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (18) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (18) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (18) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (18) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (18) (4) (2) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (39) (2) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (39) (2) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (39) (2) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (39) (2) (3) (3) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (49) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (49) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (49) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/image (49) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/image (49) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/image (49) (2) (2) (2) (2) (2) (2) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/provide_neth (1) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/provide_neth (1) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/provide_neth (1) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+ .gitbook/assets/provide_neth (1) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (1).png
+ .gitbook/assets/provide_neth (1) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (2).png
+ .gitbook/assets/provide_neth (1) (1) (4) (4) (4) (1) (1) (1) (1) (1) (1) (1) (1) (3).png
+5 −2 SUMMARY.md
+0 −2 ethereum-client/configuration/init.md
+1 −1 ethereum-client/configuration/jsonrpc.md
+4 −0 ethereum-client/configuration/merge.md
+3 −1 ethereum-client/configuration/metrics.md
+2 −0 ethereum-client/configuration/pruning.md
+11 −0 ethereum-client/configuration/receipt.md
+10 −4 ethereum-client/configuration/sample-configuration.md
+6 −1 ethereum-client/configuration/sync.md
+1 −0 ethereum-client/json-rpc/debug.md
+14 −0 ethereum-client/json-rpc/eth.md
+1 −0 ethereum-client/json-rpc/proof.md
+1 −0 ethereum-client/json-rpc/trace.md
+8 −0 ethereum-client/metrics/README.md
+15 −1 ethereum-client/metrics/db.md
+94 −0 ethereum-client/metrics/dotnet-counters.md
+3 −3 ethereum-client/metrics/evm.md
+1 −1 ethereum-client/metrics/trie.pruning.md
+1 −1 ethereum-client/running-nethermind/running-the-client.md
+3 −7 ethereum-client/sync-modes.md
+2 −2 guides-and-helpers/deploy-nethermind-with-monitoring-stack.md
+28 −0 guides-and-helpers/how-to-reduce-database-size/README.md
+49 −17 guides-and-helpers/how-to-reduce-database-size/full-pruning.md
+46 −0 guides-and-helpers/how-to-reduce-database-size/resync-database-from-scratch.md
+13 −0 nethermind-utilities/cli/eth.md
+1 −0 nethermind-utilities/cli/proof.md
+1 −0 nethermind-utilities/cli/trace.md

0 comments on commit f2a9574

Please sign in to comment.