Skip to content

Commit

Permalink
[FAB-13534] cache pushAckTimeout in pvt data
Browse files Browse the repository at this point in the history
added pushAckTimeout to distributorImpl as a cache instead of calling viper.GetDuration all of the time

Change-Id: I2296d091f12de876029a0c01a7122ffdacc60ef6
Signed-off-by: Hagar Meir <hagar.meir@ibm.com>
  • Loading branch information
HagarMeir authored and C0rWin committed Jan 7, 2019
1 parent 367b10c commit b500322
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gossip/privdata/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"math/rand"
"sync"
"sync/atomic"
"time"

proto2 "github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/common/privdata"
Expand Down Expand Up @@ -66,6 +67,7 @@ type distributorImpl struct {
chainID string
gossipAdapter
CollectionAccessFactory
pushAckTimeout time.Duration
}

// CollectionAccessFactory an interface to generate collection access policy
Expand Down Expand Up @@ -107,6 +109,7 @@ func NewDistributor(chainID string, gossip gossipAdapter, factory CollectionAcce
chainID: chainID,
gossipAdapter: gossip,
CollectionAccessFactory: factory,
pushAckTimeout: viper.GetDuration("peer.gossip.pvtData.pushAckTimeout"),
}
}

Expand Down Expand Up @@ -199,8 +202,6 @@ func (d *distributorImpl) disseminationPlanForMsg(colAP privdata.CollectionAcces
return nil, err
}

pushAckTimeout := viper.GetDuration("peer.gossip.pvtData.pushAckTimeout")

eligiblePeers := d.eligiblePeersOfChannel(routingFilter)
identitySets := d.identitiesOfEligiblePeers(eligiblePeers, colAP)

Expand All @@ -216,7 +217,7 @@ func (d *distributorImpl) disseminationPlanForMsg(colAP privdata.CollectionAcces
}
peer2SendPerOrg := selectionPeers[rand.Intn(len(selectionPeers))]
sc := gossip2.SendCriteria{
Timeout: pushAckTimeout,
Timeout: d.pushAckTimeout,
Channel: gossipCommon.ChainID(d.chainID),
MaxPeers: 1,
MinAck: required,
Expand Down Expand Up @@ -246,7 +247,7 @@ func (d *distributorImpl) disseminationPlanForMsg(colAP privdata.CollectionAcces
// criteria to select remaining peers to satisfy colAP.MaximumPeerCount()
// collection policy parameters
sc := gossip2.SendCriteria{
Timeout: pushAckTimeout,
Timeout: d.pushAckTimeout,
Channel: gossipCommon.ChainID(d.chainID),
MaxPeers: maximumPeerCount,
MinAck: requiredPeerCount,
Expand Down

0 comments on commit b500322

Please sign in to comment.