Browse Source

mempool: log hashes, not whole tx

pull/1827/head
Ethan Buchman 7 years ago
committed by Anton Kaliaev
parent
commit
fa3bd05d44
2 changed files with 8 additions and 3 deletions
  1. +7
    -2
      mempool/mempool.go
  2. +1
    -1
      mempool/reactor.go

+ 7
- 2
mempool/mempool.go View File

@ -57,6 +57,11 @@ var (
ErrMempoolIsFull = errors.New("Mempool is full") 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 // 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 // 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 // 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, tx: tx,
} }
mem.txs.PushBack(memTx) 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() mem.notifyTxsAvailable()
} else { } else {
// ignore bad transaction // 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) // remove from cache (it might be good later)
mem.cache.Remove(tx) mem.cache.Remove(tx)


+ 1
- 1
mempool/reactor.go View File

@ -90,7 +90,7 @@ func (memR *MempoolReactor) Receive(chID byte, src p2p.Peer, msgBytes []byte) {
case *TxMessage: case *TxMessage:
err := memR.Mempool.CheckTx(msg.Tx, nil) err := memR.Mempool.CheckTx(msg.Tx, nil)
if err != 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 // broadcasting happens from go routines per peer
default: default:


Loading…
Cancel
Save