Skip to content

Commit

Permalink
Resolve memory creep (#668)
Browse files Browse the repository at this point in the history
* Add proper header copying

* Enable pprof

* Remove leftover pprof import

* Simplify copying
  • Loading branch information
zivkovicmilos authored Aug 10, 2022
1 parent d3d4f8a commit e14e52a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
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

0 comments on commit e14e52a

Please sign in to comment.