Darien Raymond 8 rokov pred
rodič
commit
9cc9a76b71
1 zmenil súbory, kde vykonal 3 pridanie a 1 odobranie
  1. 3 1
      common/crypto/chunk.go

+ 3 - 1
common/crypto/chunk.go

@@ -8,11 +8,13 @@ import (
 	"v2ray.com/core/common/serial"
 )
 
+// ChunkSizeDecoder is an utility class to decode size value from bytes.
 type ChunkSizeDecoder interface {
 	SizeBytes() int
 	Decode([]byte) (uint16, error)
 }
 
+// ChunkSizeEncoder is an utility class to encode size value into bytes.
 type ChunkSizeEncoder interface {
 	SizeBytes() int
 	Encode(uint16, []byte) []byte
@@ -134,7 +136,7 @@ func (w *ChunkStreamWriter) Write(mb buf.MultiBuffer) error {
 		slice := mb.SliceBySize(sliceSize)
 
 		b := buf.New()
-		common.Must(b.AppendSupplier(func(buffer []byte) (int, error) {
+		common.Must(b.Reset(func(buffer []byte) (int, error) {
 			w.sizeEncoder.Encode(uint16(slice.Len()), buffer[:0])
 			return w.sizeEncoder.SizeBytes(), nil
 		}))