wire/server: allocate hash once per loop to prevent overwriting
This commit is contained in:
parent
71ccc95502
commit
ba4a2f77a5
2 changed files with 2 additions and 2 deletions
|
@ -839,7 +839,6 @@ func (sp *serverPeer) OnGetCFHeaders(_ *peer.Peer, msg *wire.MsgGetCFHeaders) {
|
||||||
|
|
||||||
// Generate cfheaders message and send it.
|
// Generate cfheaders message and send it.
|
||||||
headersMsg := wire.NewMsgCFHeaders()
|
headersMsg := wire.NewMsgCFHeaders()
|
||||||
var header chainhash.Hash
|
|
||||||
for i := range hashList {
|
for i := range hashList {
|
||||||
// Fetch the raw committed filter header bytes from the
|
// Fetch the raw committed filter header bytes from the
|
||||||
// database.
|
// database.
|
||||||
|
@ -852,6 +851,7 @@ func (sp *serverPeer) OnGetCFHeaders(_ *peer.Peer, msg *wire.MsgGetCFHeaders) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deserialize the hash.
|
// Deserialize the hash.
|
||||||
|
var header chainhash.Hash
|
||||||
err = header.SetBytes(headerBytes)
|
err = header.SetBytes(headerBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
peerLog.Warnf("Committed filter header deserialize "+
|
peerLog.Warnf("Committed filter header deserialize "+
|
||||||
|
|
|
@ -60,9 +60,9 @@ func (msg *MsgCFHeaders) BtcDecode(r io.Reader, pver uint32) error {
|
||||||
|
|
||||||
// Create a contiguous slice of headers to deserialize into in order to
|
// Create a contiguous slice of headers to deserialize into in order to
|
||||||
// reduce the number of allocations.
|
// reduce the number of allocations.
|
||||||
var cfh chainhash.Hash
|
|
||||||
msg.HeaderHashes = make([]*chainhash.Hash, 0, count)
|
msg.HeaderHashes = make([]*chainhash.Hash, 0, count)
|
||||||
for i := uint64(0); i < count; i++ {
|
for i := uint64(0); i < count; i++ {
|
||||||
|
var cfh chainhash.Hash
|
||||||
err := readElement(r, &cfh)
|
err := readElement(r, &cfh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue