Skip to content

Commit

Permalink
move headHash to stack
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes committed Jan 3, 2025
1 parent 95c17f0 commit fde356a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ func (p *Pool) Push(userTxn *BroadcastedTransaction) error {
func (p *Pool) Pop() (BroadcastedTransaction, error) {
var nextTxn BroadcastedTransaction
return nextTxn, p.db.Update(func(txn db.Transaction) error {
headHash, err := p.headHash(txn)
headHash := new(felt.Felt)
err := p.headHash(txn, headHash)
if err != nil {
return err
}
Expand Down Expand Up @@ -198,10 +199,9 @@ func (p *Pool) updateLen(txn db.Transaction, l uint64) error {
return txn.Set([]byte(poolLengthKey), binary.BigEndian.AppendUint64(nil, l))
}

func (p *Pool) headHash(txn db.Transaction) (*felt.Felt, error) {
var head *felt.Felt
return head, txn.Get([]byte(headKey), func(b []byte) error {
head = new(felt.Felt).SetBytes(b)
func (p *Pool) headHash(txn db.Transaction, head *felt.Felt) error {
return txn.Get([]byte(headKey), func(b []byte) error {
head.SetBytes(b)
return nil
})
}
Expand Down

0 comments on commit fde356a

Please sign in to comment.