Skip to content

Commit

Permalink
rlp: add WriteString method on EncoderBuffer (#24425)
Browse files Browse the repository at this point in the history
rlpgen outputs calls to this method for values of type string.
  • Loading branch information
ucwong committed Feb 24, 2022
1 parent 0cb4d65 commit 687e4dc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rlp/encbuffer.go
Expand Up @@ -118,6 +118,10 @@ func (buf *encBuffer) writeBytes(b []byte) {
}
}

func (buf *encBuffer) writeString(s string) {
buf.writeBytes([]byte(s))
}

// wordBytes is the number of bytes in a big.Word
const wordBytes = (32 << (uint64(^big.Word(0)) >> 63)) / 8

Expand Down Expand Up @@ -340,6 +344,11 @@ func (w EncoderBuffer) WriteBytes(b []byte) {
w.buf.writeBytes(b)
}

// WriteBytes encodes s as an RLP string.
func (w EncoderBuffer) WriteString(s string) {
w.buf.writeString(s)
}

// List starts a list. It returns an internal index. Call EndList with
// this index after encoding the content to finish the list.
func (w EncoderBuffer) List() int {
Expand Down

1 comment on commit 687e4dc

@mistychatmsn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misty chatman
1010 outer rd 215
San Diego CA 92154
619-541-9282

Please sign in to comment.