mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-30 23:53:41 +02:00
multi: replace usage of fastsha256 with crypto/sha256
This commit removes all instances of the fastsha256 library and replaces it with the sha256 library in the standard library. This change should see a number of performance improvements as the standard library has highly optimized assembly instructions with use vectorized instructions as the platform supports.
This commit is contained in:
@@ -2,12 +2,12 @@ package channeldb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/btcsuite/fastsha256"
|
||||
"github.com/roasbeef/btcd/wire"
|
||||
"github.com/roasbeef/btcutil"
|
||||
)
|
||||
@@ -132,7 +132,7 @@ func (d *DB) AddInvoice(i *Invoice) error {
|
||||
|
||||
// Ensure that an invoice an identical payment hash doesn't
|
||||
// already exist within the index.
|
||||
paymentHash := fastsha256.Sum256(i.Terms.PaymentPreimage[:])
|
||||
paymentHash := sha256.Sum256(i.Terms.PaymentPreimage[:])
|
||||
if invoiceIndex.Get(paymentHash[:]) != nil {
|
||||
return ErrDuplicateInvoice
|
||||
}
|
||||
@@ -285,7 +285,7 @@ func putInvoice(invoices *bolt.Bucket, invoiceIndex *bolt.Bucket,
|
||||
// Add the payment hash to the invoice index. This'll let us quickly
|
||||
// identify if we can settle an incoming payment, and also to possibly
|
||||
// allow a single invoice to have multiple payment installations.
|
||||
paymentHash := fastsha256.Sum256(i.Terms.PaymentPreimage[:])
|
||||
paymentHash := sha256.Sum256(i.Terms.PaymentPreimage[:])
|
||||
if err := invoiceIndex.Put(paymentHash[:], invoiceKey[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user