build+chain: replace pebbe/zmq4 with lightninglabs/gozmq (native Go)

This commit is contained in:
Alex 2018-01-12 18:44:00 -07:00 committed by Olaoluwa Osuntokun
parent a16bfd7775
commit 30d84da3e5
3 changed files with 22 additions and 43 deletions

View file

@ -5,10 +5,11 @@ import (
"container/list" "container/list"
"encoding/hex" "encoding/hex"
"errors" "errors"
"net"
"sync" "sync"
"time" "time"
"github.com/pebbe/zmq4" "github.com/lightninglabs/gozmq"
"github.com/roasbeef/btcd/btcjson" "github.com/roasbeef/btcd/btcjson"
"github.com/roasbeef/btcd/chaincfg" "github.com/roasbeef/btcd/chaincfg"
"github.com/roasbeef/btcd/chaincfg/chainhash" "github.com/roasbeef/btcd/chaincfg/chainhash"
@ -511,44 +512,13 @@ func (c *BitcoindClient) socketHandler() {
defer c.wg.Done() defer c.wg.Done()
// Connect a ZMQ socket for block notifications // Connect a ZMQ socket for block notifications
zmqCtx, err := zmq4.NewContext() zmqClient, err := gozmq.Subscribe(c.zmqConnect, []string{"rawblock",
if err != nil { "rawtx"}, c.zmqPollInterval)
log.Error(err)
return
}
defer func() {
if zmqCtx != nil {
err = zmqCtx.Term()
log.Infof("ZMQ context terminated: %v\n", err)
}
}()
zmqClient, err := zmqCtx.NewSocket(zmq4.SUB)
if err != nil {
log.Error(err)
return
}
defer func() {
if zmqClient != nil {
err = zmqClient.Close()
log.Infof("ZMQ socket closed: %v\n", err)
}
}()
err = zmqClient.SetSubscribe("rawblock")
if err != nil {
log.Error(err)
return
}
err = zmqClient.SetSubscribe("rawtx")
if err != nil {
log.Error(err)
return
}
err = zmqClient.SetRcvtimeo(c.zmqPollInterval)
err = zmqClient.Connect(c.zmqConnect)
if err != nil { if err != nil {
log.Error(err) log.Error(err)
return return
} }
defer zmqClient.Close()
log.Infof("Started listening for blocks via ZMQ on %s", c.zmqConnect) log.Infof("Started listening for blocks via ZMQ on %s", c.zmqConnect)
c.onClientConnect() c.onClientConnect()
@ -635,12 +605,16 @@ mainLoop:
} }
// Now, poll events from bitcoind. // Now, poll events from bitcoind.
msgBytes, err := zmqClient.RecvMessageBytes(0) msgBytes, err := zmqClient.Receive()
if err == zmq4.Errno(0xb) { // EAGAIN - timeout on recv
continue mainLoop
}
if err != nil { if err != nil {
switch e := err.(type) {
case net.Error:
if !e.Timeout() {
log.Error(err) log.Error(err)
}
default:
log.Error(err)
}
continue mainLoop continue mainLoop
} }

9
glide.lock generated
View file

@ -10,6 +10,7 @@
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD <<<<<<< HEAD
<<<<<<< HEAD
hash: 2fe59efc96b0a2839297653da88cde89208f8f8cf4ced2bb1e828def57e3611b hash: 2fe59efc96b0a2839297653da88cde89208f8f8cf4ced2bb1e828def57e3611b
updated: 2017-07-19T11:33:58.0769452-04:00 updated: 2017-07-19T11:33:58.0769452-04:00
======= =======
@ -59,6 +60,10 @@ updated: 2017-11-18T15:17:20.95646706-08:00
hash: 83bb1c0a0f5c6396d2387746544592662898af52596d5cdca898b6fbfaa60841 hash: 83bb1c0a0f5c6396d2387746544592662898af52596d5cdca898b6fbfaa60841
updated: 2017-11-29T14:42:36.82153259-06:00 updated: 2017-11-29T14:42:36.82153259-06:00
>>>>>>> 7a32017... multi: add bitcoind back-end (only for API use for now) >>>>>>> 7a32017... multi: add bitcoind back-end (only for API use for now)
=======
hash: 8fdbf966a888ff626d377d985e34c32518f81e96dc661433184ce011bad062b2
updated: 2018-01-12T18:42:39.220877425-07:00
>>>>>>> 6c1491e... build+chain: replace pebbe/zmq4 with lightninglabs/gozmq (native Go)
imports: imports:
- name: github.com/aead/siphash - name: github.com/aead/siphash
version: e404fcfc888570cadd1610538e2dbc89f66af814 version: e404fcfc888570cadd1610538e2dbc89f66af814
@ -179,8 +184,8 @@ imports:
subpackages: subpackages:
- filterdb - filterdb
- headerfs - headerfs
- name: github.com/pebbe/zmq4 - name: github.com/lightninglabs/gozmq
version: 90d69e412a09549f2e90bac70fbb449081f1e5c1 version: b0bbb30a99d00b25c3304994d20aac68607b75c0
- name: github.com/roasbeef/btcd - name: github.com/roasbeef/btcd
version: 5d9e4e1fa749fa2f1675802a4c9f10ef0ada04d1 version: 5d9e4e1fa749fa2f1675802a4c9f10ef0ada04d1
subpackages: subpackages:

View file

@ -43,7 +43,7 @@ import:
- package: github.com/jrick/logrotate - package: github.com/jrick/logrotate
subpackages: subpackages:
- rotator - rotator
- package: github.com/pebbe/zmq4 - package: github.com/lightninglabs/gozmq
testImport: testImport:
- package: github.com/davecgh/go-spew - package: github.com/davecgh/go-spew
subpackages: subpackages: