mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 09:50:08 +01:00
simplify s[:] to s where s is a slice
Found using https://go-critic.github.io/overview#unslice-ref
This commit is contained in:
parent
e9c7a5ac64
commit
0886f1e5c1
@ -120,7 +120,7 @@ func dbFetchVersion(dbTx database.Tx, key []byte) uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
return byteOrder.Uint32(serialized[:])
|
||||
return byteOrder.Uint32(serialized)
|
||||
}
|
||||
|
||||
// dbPutVersion uses an existing database transaction to update the provided
|
||||
@ -943,7 +943,7 @@ func serializeBestChainState(state bestChainState) []byte {
|
||||
byteOrder.PutUint32(serializedData[offset:], workSumBytesLen)
|
||||
offset += 4
|
||||
copy(serializedData[offset:], workSumBytes)
|
||||
return serializedData[:]
|
||||
return serializedData
|
||||
}
|
||||
|
||||
// deserializeBestChainState deserializes the passed serialized best chain
|
||||
|
@ -474,7 +474,7 @@ func (s *blockStore) writeBlock(rawBlock []byte) (blockLocation, error) {
|
||||
_, _ = hasher.Write(scratch[:])
|
||||
|
||||
// Serialized block.
|
||||
if err := s.writeData(rawBlock[:], "block"); err != nil {
|
||||
if err := s.writeData(rawBlock, "block"); err != nil {
|
||||
return blockLocation{}, err
|
||||
}
|
||||
_, _ = hasher.Write(rawBlock)
|
||||
|
@ -68,7 +68,7 @@ func (fr *fixedReader) Read(p []byte) (n int, err error) {
|
||||
func newFixedReader(max int, buf []byte) io.Reader {
|
||||
b := make([]byte, max)
|
||||
if buf != nil {
|
||||
copy(b[:], buf)
|
||||
copy(b, buf)
|
||||
}
|
||||
|
||||
iobuf := bytes.NewBuffer(b)
|
||||
|
@ -401,7 +401,7 @@ func ReadMessageWithEncodingN(r io.Reader, pver uint32, btcnet BitcoinNet,
|
||||
|
||||
// Test checksum.
|
||||
checksum := chainhash.DoubleHashB(payload)[0:4]
|
||||
if !bytes.Equal(checksum[:], hdr.checksum[:]) {
|
||||
if !bytes.Equal(checksum, hdr.checksum[:]) {
|
||||
str := fmt.Sprintf("payload checksum failed - header "+
|
||||
"indicates %v, but actual checksum is %v.",
|
||||
hdr.checksum, checksum)
|
||||
|
Loading…
Reference in New Issue
Block a user