Skip to content

Commit

Permalink
refactor: opinion hasher to be pooled
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Jun 17, 2024
1 parent c74972d commit fb48a6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions common/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ func (p *Proposal) HashInnerProposal() []byte {
if err != nil {
log.With().Fatal("failed to encode InnerProposal for hashing", log.Err(err))
}
sum := h.Sum(nil)
return sum
return h.Sum(nil)
}

// ID returns the ProposalID.
Expand Down
6 changes: 4 additions & 2 deletions tortoise/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ type layerInfo struct {
}

func (l *layerInfo) computeOpinion(hdist uint32, last types.LayerID) {
hasher := opinionhash.New()
hasher := opinionhash.GetHasher()

Check failure on line 183 in tortoise/state.go

View workflow job for this annotation

GitHub Actions / coverage

undefined: opinionhash.GetHasher
defer opinionhash.PutHasher(hasher)

Check failure on line 184 in tortoise/state.go

View workflow job for this annotation

GitHub Actions / coverage

undefined: opinionhash.PutHasher
if l.prevOpinion != nil {
hasher.WritePrevious(*l.prevOpinion)
}
Expand Down Expand Up @@ -372,7 +373,8 @@ func (l *layerVote) sortSupported() {
}

func (l *layerVote) computeOpinion() {
hasher := opinionhash.New()
hasher := opinionhash.GetHasher()

Check failure on line 376 in tortoise/state.go

View workflow job for this annotation

GitHub Actions / coverage

undefined: opinionhash.GetHasher
defer opinionhash.PutHasher(hasher)

Check failure on line 377 in tortoise/state.go

View workflow job for this annotation

GitHub Actions / coverage

undefined: opinionhash.PutHasher
if l.prev != nil {
hasher.WritePrevious(l.prev.opinion)
}
Expand Down

0 comments on commit fb48a6e

Please sign in to comment.