From fa3bd05d44729806d3a073dce87f86f18b1d9ac6 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 22 Jun 2018 15:06:43 -0400 Subject: [PATCH] mempool: log hashes, not whole tx --- mempool/mempool.go | 9 +++++++-- mempool/reactor.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mempool/mempool.go b/mempool/mempool.go index 8c9e41d59..1d12108d9 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -57,6 +57,11 @@ var ( ErrMempoolIsFull = errors.New("Mempool is full") ) +// TxID is the hex encoded hash of the bytes as a types.Tx. +func TxID(tx []byte) string { + return fmt.Sprintf("%X", types.Tx(tx).Hash()) +} + // Mempool is an ordered in-memory pool for transactions before they are proposed in a consensus // round. Transaction validity is checked using the CheckTx abci message before the transaction is // added to the pool. The Mempool uses a concurrent list structure for storing transactions that @@ -288,11 +293,11 @@ func (mem *Mempool) resCbNormal(req *abci.Request, res *abci.Response) { tx: tx, } mem.txs.PushBack(memTx) - mem.logger.Info("Added good transaction", "tx", fmt.Sprintf("%X", types.Tx(tx).Hash()), "res", r) + mem.logger.Info("Added good transaction", "tx", TxID(tx), "res", r) mem.notifyTxsAvailable() } else { // ignore bad transaction - mem.logger.Info("Rejected bad transaction", "tx", fmt.Sprintf("%X", types.Tx(tx).Hash()), "res", r) + mem.logger.Info("Rejected bad transaction", "tx", TxID(tx), "res", r) // remove from cache (it might be good later) mem.cache.Remove(tx) diff --git a/mempool/reactor.go b/mempool/reactor.go index d6cebfbf3..fab9480ba 100644 --- a/mempool/reactor.go +++ b/mempool/reactor.go @@ -90,7 +90,7 @@ 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", msg.Tx, "err", err) + memR.Logger.Info("Could not check tx", "tx", TxID(msg.Tx), "err", err) } // broadcasting happens from go routines per peer default: