Skip to content

Commit 5a8973d

Browse files
committed
[FAB-1889]: Expecting block 2 instead of block 1.
Since FAB-1872 takes care to commit the genesis blocks for the first time it comes with join channel command there is a need to adjust GossipStateTransfer. This commit takes care to make adjustment for gossip payloads reordering buffer. Change-Id: I7ec85dc17d2a0e65939aa6dfec4989edf9cc4c83 Signed-off-by: Artem Barger <[email protected]>
1 parent cf28448 commit 5a8973d

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

core/deliverservice/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
var logger *logging.Logger // package-level logger
3939

4040
func init() {
41-
logger = logging.MustGetLogger("noopssinglechain.client")
41+
logger = logging.MustGetLogger("deliveryService")
4242
}
4343

4444
// DeliverService used to communicate with orderers to obtain

gossip/state/state.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func NewGossipStateProvider(chainID string, g gossip.Gossip, committer committer
126126

127127
stopFlag: 0,
128128
// Create a queue for payload received
129-
payloads: NewPayloadsBuffer(height + 1),
129+
payloads: NewPayloadsBuffer(height),
130130

131131
committer: committer,
132132

@@ -329,17 +329,12 @@ func (s *GossipStateProviderImpl) antiEntropy() {
329329
}
330330
}
331331
}
332+
s.logger.Debug("[XXX]: Stateprovider stopped, stoping anti entropy procedure.")
332333

333334
if current == max {
334-
// No messages in the buffer or there are no gaps
335-
//s.logger.Debugf("Current ledger height is the same as ledger height on other peers.")
336335
continue
337336
}
338337

339-
if current > 0 {
340-
current = current + 1
341-
}
342-
//s.logger.Debugf("Requesting new blocks in range [%d...%d].", current+1, max)
343338
s.requestBlocksInRange(uint64(current), uint64(max))
344339
}
345340
s.logger.Debug("[XXX]: Stateprovider stopped, stoping anti entropy procedure.")

gossip/state/state_test.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
pb "github.com/golang/protobuf/proto"
28+
"github.com/hyperledger/fabric/common/configtx/test"
2829
"github.com/hyperledger/fabric/common/util"
2930
"github.com/hyperledger/fabric/core/committer"
3031
"github.com/hyperledger/fabric/core/ledger/ledgermgmt"
@@ -123,7 +124,7 @@ func (*naiveCryptoService) ValidateIdentity(peerIdentity api.PeerIdentityType) e
123124
func bootPeers(ids ...int) []string {
124125
peers := []string{}
125126
for _, id := range ids {
126-
peers = append(peers, fmt.Sprintf("localhost:%d", (id+portPrefix)))
127+
peers = append(peers, fmt.Sprintf("localhost:%d", id+portPrefix))
127128
}
128129
return peers
129130
}
@@ -172,6 +173,8 @@ func newGossipInstance(config *gossip.Config) gossip.Gossip {
172173
// Create new instance of KVLedger to be used for testing
173174
func newCommitter(id int) committer.Committer {
174175
ledger, _ := ledgermgmt.CreateLedger(strconv.Itoa(id))
176+
cb, _ := test.MakeGenesisBlock(util.GetTestChainID())
177+
ledger.Commit(cb)
175178
return committer.NewLedgerCommitter(ledger, &validator.MockValidator{})
176179
}
177180

@@ -334,8 +337,8 @@ func TestNewGossipStateProvider_SendingManyMessages(t *testing.T) {
334337
logger.Debug("[*****]: Trying to see all peers get all blocks")
335338
for _, p := range peersSet {
336339
height, err := p.commit.LedgerHeight()
337-
if height != uint64(msgCount) || err != nil {
338-
logger.Debug("[XXXXXXX]: Ledger height is at: ", height)
340+
if height != uint64(msgCount+1) || err != nil {
341+
//logger.Debug("[XXXXXXX]: Ledger height is at: ", height)
339342
return false
340343
}
341344
}

0 commit comments

Comments
 (0)