chain/bitcoind_conn: only print ASCII rawtx event types

This commit is contained in:
Conner Fromknecht 2018-08-31 15:55:27 -07:00
parent 7b84dc25a6
commit 042d409236
No known key found for this signature in database
GPG key ID: E7D737B67FA592C7

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