use buffer instead of 2 write calls

for greater performance
This commit is contained in:
Anton Kaliaev
2018-07-10 16:11:50 +04:00
parent 0030a8e697
commit 71e4870660

View File

@@ -247,12 +247,11 @@ func (mem *Mempool) CheckTx(tx types.Tx, cb func(*abci.Response)) (err error) {
// WAL
if mem.wal != nil {
var buf bytes.Buffer
buf.Write([]byte(tx))
buf.Write([]byte("\n"))
// TODO: Notify administrators when WAL fails
_, err := mem.wal.Write([]byte(tx))
if err != nil {
mem.logger.Error("Error writing to WAL", "err", err)
}
_, err = mem.wal.Write([]byte("\n"))
_, err := mem.wal.Write(buf.Bytes())
if err != nil {
mem.logger.Error("Error writing to WAL", "err", err)
}