Skip to content

Commit

Permalink
temp changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nsa committed Sep 7, 2017
1 parent 9499708 commit 36f3cc3
Show file tree
Hide file tree
Showing 38 changed files with 57 additions and 26 deletions.
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-aead-chacha20
Submodule https-github.com-aead-chacha20 added at d31a91
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-aead-siphash
Submodule https-github.com-aead-siphash added at e404fc
Submodule https-github.com-awalterschulze-gographviz added at 9d8c97
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-boltdb-bolt
Submodule https-github.com-boltdb-bolt added at 2f1ce7
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-btcsuite-btclog
Submodule https-github.com-btcsuite-btclog added at 84c8d2
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-btcsuite-fastsha256
Submodule https-github.com-btcsuite-fastsha256 added at 637e65
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-btcsuite-go-flags
Submodule https-github.com-btcsuite-go-flags added at 6c288d
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-btcsuite-go-socks
Submodule https-github.com-btcsuite-go-socks added at 472003
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-btcsuite-golangcrypto
Submodule https-github.com-btcsuite-golangcrypto added at 53f62d
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-btcsuite-websocket
Submodule https-github.com-btcsuite-websocket added at 31079b
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-davecgh-go-spew
Submodule https-github.com-davecgh-go-spew added at 346938
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-go-errors-errors
Submodule https-github.com-go-errors-errors added at 8fa88b
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-golang-protobuf
Submodule https-github.com-golang-protobuf added at 5afd06
Submodule https-github.com-grpc-ecosystem-grpc-gateway added at f2862b
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-howeyc-gopass
Submodule https-github.com-howeyc-gopass added at bf9dde
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-jrick-logrotate
Submodule https-github.com-jrick-logrotate added at a93b20
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-juju-loggo
Submodule https-github.com-juju-loggo added at 8232ab
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-kkdai-bstream
Submodule https-github.com-kkdai-bstream added at f391b8
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-lightninglabs-neutrino
Submodule https-github.com-lightninglabs-neutrino added at 69a3bc
Submodule https-github.com-lightningnetwork-lightning-onion added at a164ed
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-ltcsuite-ltcd
Submodule https-github.com-ltcsuite-ltcd added at 5f654d
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-roasbeef-btcd
Submodule https-github.com-roasbeef-btcd added at 4b411f
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-roasbeef-btcrpcclient
Submodule https-github.com-roasbeef-btcrpcclient added at d0f4db
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-roasbeef-btcutil
Submodule https-github.com-roasbeef-btcutil added at 158402
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-roasbeef-btcwallet
Submodule https-github.com-roasbeef-btcwallet added at e4e29c
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-rogpeppe-fastuuid
Submodule https-github.com-rogpeppe-fastuuid added at 6724a5
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-tv42-zbase32
Submodule https-github.com-tv42-zbase32 added at 501572
1 change: 1 addition & 0 deletions .glide/cache/src/https-github.com-urfave-cli
Submodule https-github.com-urfave-cli added at cfb388
1 change: 1 addition & 0 deletions .glide/cache/src/https-golang.org-x-crypto
Submodule https-golang.org-x-crypto added at 81e909
1 change: 1 addition & 0 deletions .glide/cache/src/https-golang.org-x-net
Submodule https-golang.org-x-net added at 66aace
1 change: 1 addition & 0 deletions .glide/cache/src/https-golang.org-x-sys
Submodule https-golang.org-x-sys added at a07a69
1 change: 1 addition & 0 deletions .glide/cache/src/https-golang.org-x-text
Submodule https-golang.org-x-text added at 79ab41
1 change: 1 addition & 0 deletions .glide/cache/src/https-google.golang.org-genproto
Submodule https-google.golang.org-genproto added at ee236b
1 change: 1 addition & 0 deletions .glide/cache/src/https-google.golang.org-grpc
Submodule https-google.golang.org-grpc added at b3ddf7
1 change: 1 addition & 0 deletions .glide/cache/src/https-gopkg.in-errgo.v1
Submodule https-gopkg.in-errgo.v1 added at 442357
1 change: 1 addition & 0 deletions .glide/cache/src/https-gopkg.in-macaroon-bakery.v1
Submodule https-gopkg.in-macaroon-bakery.v1 added at 8e14f8
1 change: 1 addition & 0 deletions .glide/cache/src/https-gopkg.in-macaroon.v1
Submodule https-gopkg.in-macaroon.v1 added at ab1017
46 changes: 20 additions & 26 deletions fundingmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func (f *fundingManager) Start() error {
// resume wait on startup.
case err = <-errChan:
// Encountered an error
fndgLog.Errorf("Encountered an error")
fndgLog.Errorf("error registering for confirmation: %v", err)
case confDetails := <-confirmChan:
// Successfully received confirmation details from
// confirmChan. Now we can call processConfirmedFunding
Expand Down Expand Up @@ -446,6 +446,7 @@ func (f *fundingManager) Start() error {
f.wg.Add(1)
go func() {
defer f.wg.Done()
// TODO - sendFund
f.sendFundingLockedAndAnnounceChannel(channel,
shortChanID)
}()
Expand Down Expand Up @@ -1081,13 +1082,13 @@ func (f *fundingManager) handleFundingCreated(fmsg *fundingCreatedMsg) {
// wait for funding transaction on startup.
case err := <-errChan:
// Encountered an error
fndgLog.Errorf("Encountered an error: %v", err)
fndgLog.Errorf("error waiting for funding transaction to confirm: %v", err)
case confDetails := <-confirmChan:
// Now we can call processConfirmedFunding
f.processConfirmedFunding(completeChan, confDetails)
// Success, funding transaction was confirmed.
f.deleteReservationCtx(peerKey,
fmsg.msg.PendingChannelID)
// Now we can call processConfirmedFunding
f.processConfirmedFunding(completeChan, confDetails)
}
}()
}
Expand Down Expand Up @@ -1189,7 +1190,7 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
case <-f.quit:
return
case err := <-errChan:
fndgLog.Errorf("Encountered an error: %v", err)
fndgLog.Errorf("error waiting for funding transaction to confirm: %v", err)
return
case confDetails := <-confirmChan:
// Successfully received confirmation details
Expand Down Expand Up @@ -1222,8 +1223,8 @@ func (f *fundingManager) handleFundingSigned(fmsg *fundingSignedMsg) {
// passed from bestHeight. In the case of timeout, the timeoutChan will be
// closed. In case of confirmation or error, doneChan will be closed.
func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenChannel,
errChan chan<- error, timeoutChan chan<- struct{},
confirmChan chan<- *chainntnfs.TxConfirmation) {
confirmChan chan<- *chainntnfs.TxConfirmation, timeoutChan chan<- struct{},
errChan chan<- error) {

epochClient, err := f.cfg.Notifier.RegisterBlockEpochNtfn()
if err != nil {
Expand Down Expand Up @@ -1296,16 +1297,13 @@ func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenC
// when a channel has become active for lightning transactions.
// The wait can be canceled by closing the cancelChan.
func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.OpenChannel,
cancelChan <-chan struct{}, errChan chan<- error,
confirmChan chan<- *chainntnfs.TxConfirmation) {
cancelChan <-chan struct{}, confirmChan chan<- *chainntnfs.TxConfirmation,
errChan chan<- error) {

// Register with the ChainNotifier for a notification once the funding
// transaction reaches `numConfs` confirmations.
txid := completeChan.FundingOutpoint.Hash
numConfs := uint32(completeChan.NumConfsRequired)
if (numConfs < 6) {
numConfs = 6
}
confNtfn, err := f.cfg.Notifier.RegisterConfirmationsNtfn(&txid,
numConfs, completeChan.FundingBroadcastHeight)
if err != nil {
Expand All @@ -1318,14 +1316,19 @@ func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.Open
fndgLog.Infof("Waiting for funding tx (%v) to reach %v confirmations",
txid, numConfs)

var confDetails *chainntnfs.TxConfirmation
var ok bool

// Wait until the specified number of confirmations has been reached,
// we get a cancel signal, or the wallet signals a shutdown.
select {
case confDetails, ok = <-confNtfn.Confirmed:
// fallthrough
case confDetails, ok := <-confNtfn.Confirmed:
if !ok {
fndgLog.Warnf("ChainNotifier shutting down, cannot complete "+
"funding flow for ChannelPoint(%v)",
completeChan.FundingOutpoint)
return
}

// Send confirmation details to confirmChan for use in processConfirmedFunding
confirmChan <- confDetails
case <-cancelChan:
fndgLog.Warnf("canceled waiting for funding confirmation, "+
"stopping funding flow for ChannelPoint(%v)",
Expand All @@ -1337,15 +1340,6 @@ func (f *fundingManager) waitForFundingConfirmation(completeChan *channeldb.Open
return
}

if !ok {
fndgLog.Warnf("ChainNotifier shutting down, cannot complete "+
"funding flow for ChannelPoint(%v)",
completeChan.FundingOutpoint)
return
}

// Send confirmation details to confirmChan for use in processConfirmedFunding
confirmChan <- confDetails
}

// processConfirmedFunding marks a fully confirmed channel as open and available
Expand Down

0 comments on commit 36f3cc3

Please sign in to comment.