Compare commits

...

3 Commits

Author SHA1 Message Date
Anton Kaliaev
60dd8067ae var name according to Go standards 2018-07-10 16:13:43 +04:00
Anton Kaliaev
2cd206e329 debug level for ErrTxInCache 2018-07-10 16:12:42 +04:00
Anton Kaliaev
71e4870660 use buffer instead of 2 write calls
for greater performance
2018-07-10 16:11:50 +04:00
2 changed files with 11 additions and 8 deletions

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)
}

View File

@@ -90,7 +90,11 @@ func (memR *MempoolReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
case *TxMessage:
err := memR.Mempool.CheckTx(msg.Tx, nil)
if err != nil {
memR.Logger.Info("Could not check tx", "tx", TxID(msg.Tx), "err", err)
if err != ErrTxInCache {
memR.Logger.Error("Could not check tx", "tx", TxID(msg.Tx), "err", err)
} else {
memR.Logger.Debug("Could not check tx", "tx", TxID(msg.Tx), "err", err)
}
}
// broadcasting happens from go routines per peer
default:
@@ -135,8 +139,8 @@ func (memR *MempoolReactor) broadcastTxRoutine(peer p2p.Peer) {
memTx := next.Value.(*mempoolTx)
// make sure the peer is up to date
height := memTx.Height()
if peerState_i := peer.Get(types.PeerStateKey); peerState_i != nil {
peerState := peerState_i.(PeerState)
if peerStateI := peer.Get(types.PeerStateKey); peerStateI != nil {
peerState := peerStateI.(PeerState)
peerHeight := peerState.GetHeight()
if peerHeight < height-1 { // Allow for a lag of 1 block
time.Sleep(peerCatchupSleepIntervalMS * time.Millisecond)