peer: declare QueueMessage()'s doneChan as send only.

Contains the following upstream commits:
- e08038115b
  - This commit has already been cherry-picked so it is a NOOP
- 391d5e4a01
  - This commit has been replaced by a new commit that was cherry-picked
    so it has been converted to a NOOP
- c1861bc8fa
This commit is contained in:
Dave Collins 2016-05-30 13:41:17 -05:00
commit 6febb7b244
2 changed files with 8 additions and 8 deletions

View File

@ -305,7 +305,7 @@ func newNetAddress(addr net.Addr, services wire.ServiceFlag) (*wire.NetAddress,
// shutdown)
type outMsg struct {
msg wire.Message
doneChan chan struct{}
doneChan chan<- struct{}
}
// stallControlCmd represents the command of a stall control message.
@ -1863,7 +1863,7 @@ cleanup:
// QueueMessage adds the passed wire message to the peer send queue.
//
// This function is safe for concurrent access.
func (p *Peer) QueueMessage(msg wire.Message, doneChan chan struct{}) {
func (p *Peer) QueueMessage(msg wire.Message, doneChan chan<- struct{}) {
// Avoid risk of deadlock if goroutine already exited. The goroutine
// we will be sending to hangs around until it knows for a fact that
// it is marked as disconnected and *then* it drains the channels.

View File

@ -1066,7 +1066,7 @@ func (s *server) AnnounceNewTransactions(newTxs []*dcrutil.Tx) {
// pushTxMsg sends a tx message for the provided transaction hash to the
// connected peer. An error is returned if the transaction hash is not known.
func (s *server) pushTxMsg(sp *serverPeer, sha *chainhash.Hash, doneChan, waitChan chan struct{}) error {
func (s *server) pushTxMsg(sp *serverPeer, sha *chainhash.Hash, doneChan chan<- struct{}, waitChan <-chan struct{}) error {
// Attempt to fetch the requested transaction from the pool. A
// call could be made to check for existence first, but simply trying
// to fetch a missing transaction results in the same behavior.
@ -1093,7 +1093,7 @@ func (s *server) pushTxMsg(sp *serverPeer, sha *chainhash.Hash, doneChan, waitCh
// pushBlockMsg sends a block message for the provided block hash to the
// connected peer. An error is returned if the block hash is not known.
func (s *server) pushBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneChan, waitChan chan struct{}) error {
func (s *server) pushBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneChan chan<- struct{}, waitChan <-chan struct{}) error {
blk, err := s.blockManager.GetBlockFromHash(*sha)
if err != nil {
peerLog.Tracef("Unable to fetch requested block sha %v: %v",
@ -1112,7 +1112,7 @@ func (s *server) pushBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneChan, wai
// We only send the channel for this message if we aren't sending
// an inv straight after.
var dc chan struct{}
var dc chan<- struct{}
continueHash := sp.continueHash
sendInv := continueHash != nil && continueHash.IsEqual(sha)
if !sendInv {
@ -1144,7 +1144,7 @@ func (s *server) pushBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneChan, wai
// the connected peer. Since a merkle block requires the peer to have a filter
// loaded, this call will simply be ignored if there is no filter loaded. An
// error is returned if the block hash is not known.
func (s *server) pushMerkleBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneChan, waitChan chan struct{}) error {
func (s *server) pushMerkleBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneChan chan<- struct{}, waitChan <-chan struct{}) error {
// Do not send a response if the peer doesn't have a filter loaded.
if !sp.filter.IsLoaded() {
if doneChan != nil {
@ -1175,7 +1175,7 @@ func (s *server) pushMerkleBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneCha
// Send the merkleblock. Only send the done channel with this message
// if no transactions will be sent afterwards.
var dc chan struct{}
var dc chan<- struct{}
if len(matchedTxIndices) == 0 {
dc = doneChan
}
@ -1185,7 +1185,7 @@ func (s *server) pushMerkleBlockMsg(sp *serverPeer, sha *chainhash.Hash, doneCha
blkTransactions := blk.MsgBlock().Transactions
for i, txIndex := range matchedTxIndices {
// Only send the done channel on the final transaction.
var dc chan struct{}
var dc chan<- struct{}
if i == len(matchedTxIndices)-1 {
dc = doneChan
}