From d5e847179419f83932a6c29a106c2e8df6be00cc Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "rlp: use identical receiver names for encBuffer methods (#27430)" This reverts commit 5e0fadb3571e276822439af0356390036f991187. --- rlp/encbuffer.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/rlp/encbuffer.go b/rlp/encbuffer.go index 8d3a3b2293..9ac4fcb2ca 100644 --- a/rlp/encbuffer.go +++ b/rlp/encbuffer.go @@ -56,18 +56,18 @@ func (buf *encBuffer) size() int { } // makeBytes creates the encoder output. -func (buf *encBuffer) makeBytes() []byte { - out := make([]byte, buf.size()) - buf.copyTo(out) +func (w *encBuffer) makeBytes() []byte { + out := make([]byte, w.size()) + w.copyTo(out) return out } -func (buf *encBuffer) copyTo(dst []byte) { +func (w *encBuffer) copyTo(dst []byte) { strpos := 0 pos := 0 - for _, head := range buf.lheads { + for _, head := range w.lheads { // write string data before header - n := copy(dst[pos:], buf.str[strpos:head.offset]) + n := copy(dst[pos:], w.str[strpos:head.offset]) pos += n strpos += n // write the header @@ -75,7 +75,7 @@ func (buf *encBuffer) copyTo(dst []byte) { pos += len(enc) } // copy string data after the last list header - copy(dst[pos:], buf.str[strpos:]) + copy(dst[pos:], w.str[strpos:]) } // writeTo writes the encoder output to w. @@ -149,34 +149,34 @@ func (buf *encBuffer) writeString(s string) { const wordBytes = (32 << (uint64(^big.Word(0)) >> 63)) / 8 // writeBigInt writes i as an integer. -func (buf *encBuffer) writeBigInt(i *big.Int) { +func (w *encBuffer) writeBigInt(i *big.Int) { bitlen := i.BitLen() if bitlen <= 64 { - buf.writeUint64(i.Uint64()) + w.writeUint64(i.Uint64()) return } // Integer is larger than 64 bits, encode from i.Bits(). // The minimal byte length is bitlen rounded up to the next // multiple of 8, divided by 8. length := ((bitlen + 7) & -8) >> 3 - buf.encodeStringHeader(length) - buf.str = append(buf.str, make([]byte, length)...) + w.encodeStringHeader(length) + w.str = append(w.str, make([]byte, length)...) index := length - bytesBuf := buf.str[len(buf.str)-length:] + buf := w.str[len(w.str)-length:] for _, d := range i.Bits() { for j := 0; j < wordBytes && index > 0; j++ { index-- - bytesBuf[index] = byte(d) + buf[index] = byte(d) d >>= 8 } } } // writeUint256 writes z as an integer. -func (buf *encBuffer) writeUint256(z *uint256.Int) { +func (w *encBuffer) writeUint256(z *uint256.Int) { bitlen := z.BitLen() if bitlen <= 64 { - buf.writeUint64(z.Uint64()) + w.writeUint64(z.Uint64()) return } nBytes := byte((bitlen + 7) / 8) @@ -186,7 +186,7 @@ func (buf *encBuffer) writeUint256(z *uint256.Int) { binary.BigEndian.PutUint64(b[17:25], z[1]) binary.BigEndian.PutUint64(b[25:33], z[0]) b[32-nBytes] = 0x80 + nBytes - buf.str = append(buf.str, b[32-nBytes:]...) + w.str = append(w.str, b[32-nBytes:]...) } // list adds a new list header to the header stack. It returns the index of the header.