Merge pull request #537 from cfromknecht/dont-print-rawtx-garbage

chain/bitcoind_conn: only print ASCII rawtx event types
This commit is contained in:
Olaoluwa Osuntokun 2018-09-03 17:55:49 -07:00 committed by GitHub
commit 0059b9fcd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -191,7 +191,8 @@ func (c *BitcoindConn) blockEventHandler(conn *gozmq.Conn) {
continue continue
} }
log.Errorf("Unable to receive ZMQ message: %v", err) log.Errorf("Unable to receive ZMQ rawblock message: %v",
err)
continue continue
} }
@ -225,7 +226,7 @@ func (c *BitcoindConn) blockEventHandler(conn *gozmq.Conn) {
// bitcoind shuts down, which will produce an unreadable // bitcoind shuts down, which will produce an unreadable
// event type. To prevent from logging it, we'll make // event type. To prevent from logging it, we'll make
// sure it conforms to the ASCII standard. // sure it conforms to the ASCII standard.
if !isASCII(eventType) { if eventType == "" || !isASCII(eventType) {
continue continue
} }
@ -266,7 +267,8 @@ func (c *BitcoindConn) txEventHandler(conn *gozmq.Conn) {
continue continue
} }
log.Errorf("Unable to receive ZMQ message: %v", err) log.Errorf("Unable to receive ZMQ rawtx message: %v",
err)
continue continue
} }
@ -296,6 +298,14 @@ func (c *BitcoindConn) txEventHandler(conn *gozmq.Conn) {
} }
c.rescanClientsMtx.Unlock() c.rescanClientsMtx.Unlock()
default: default:
// It's possible that the message wasn't fully read if
// bitcoind shuts down, which will produce an unreadable
// event type. To prevent from logging it, we'll make
// sure it conforms to the ASCII standard.
if eventType == "" || !isASCII(eventType) {
continue
}
log.Warnf("Received unexpected event type from rawtx "+ log.Warnf("Received unexpected event type from rawtx "+
"subscription: %v", eventType) "subscription: %v", eventType)
} }