mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-21 00:46:32 +00:00
filelogger to write output to a file
This commit is contained in:
@ -1,14 +1,9 @@
|
||||
package binary
|
||||
|
||||
import (
|
||||
. "github.com/tendermint/tendermint/common"
|
||||
"io"
|
||||
)
|
||||
|
||||
const (
|
||||
ByteSliceChunk = 1024
|
||||
)
|
||||
|
||||
func WriteByteSlice(bz []byte, w io.Writer, n *int64, err *error) {
|
||||
WriteVarint(len(bz), w, n, err)
|
||||
WriteTo(bz, w, n, err)
|
||||
@ -24,16 +19,8 @@ func ReadByteSlice(r io.Reader, n *int64, err *error) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
var buf, tmpBuf []byte
|
||||
// read one ByteSliceChunk at a time and append
|
||||
for i := 0; i*ByteSliceChunk < length; i++ {
|
||||
tmpBuf = make([]byte, MinInt(ByteSliceChunk, length-i*ByteSliceChunk))
|
||||
ReadFull(tmpBuf, r, n, err)
|
||||
if *err != nil {
|
||||
return nil
|
||||
}
|
||||
buf = append(buf, tmpBuf...)
|
||||
}
|
||||
buf := make([]byte, length)
|
||||
ReadFull(buf, r, n, err)
|
||||
return buf
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user