Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Resolve memory creep #668

Merged
merged 5 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ main
.vscode

# exclude build folder
artifacts
artifacts

# Log files
*.log
25 changes: 20 additions & 5 deletions types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,28 @@ func (n *Nonce) UnmarshalText(input []byte) error {
}

func (h *Header) Copy() *Header {
hh := new(Header)
*hh = *h
newHeader := &Header{
ParentHash: h.ParentHash,
Sha3Uncles: h.Sha3Uncles,
Miner: h.Miner,
StateRoot: h.StateRoot,
TxRoot: h.TxRoot,
ReceiptsRoot: h.ReceiptsRoot,
MixHash: h.MixHash,
Hash: h.Hash,
LogsBloom: h.LogsBloom,
Nonce: h.Nonce,
Difficulty: h.Difficulty,
Number: h.Number,
GasLimit: h.GasLimit,
GasUsed: h.GasUsed,
Timestamp: h.Timestamp,
}

hh.ExtraData = make([]byte, len(h.ExtraData))
copy(hh.ExtraData[:], h.ExtraData[:])
newHeader.ExtraData = make([]byte, len(h.ExtraData))
copy(newHeader.ExtraData[:], h.ExtraData[:])

return hh
return newHeader
}

type Body struct {
Expand Down