Skip to content

Commit

Permalink
[FAB-1889]: Expecting block 2 instead of block 1.
Browse files Browse the repository at this point in the history
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 <bartem@il.ibm.com>
  • Loading branch information
C0rWin committed Jan 27, 2017
1 parent cf28448 commit 5a8973d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion core/deliverservice/client.go
Expand Up @@ -38,7 +38,7 @@ import (
var logger *logging.Logger // package-level logger

func init() {
logger = logging.MustGetLogger("noopssinglechain.client")
logger = logging.MustGetLogger("deliveryService")
}

// DeliverService used to communicate with orderers to obtain
Expand Down
9 changes: 2 additions & 7 deletions gossip/state/state.go
Expand Up @@ -126,7 +126,7 @@ func NewGossipStateProvider(chainID string, g gossip.Gossip, committer committer

stopFlag: 0,
// Create a queue for payload received
payloads: NewPayloadsBuffer(height + 1),
payloads: NewPayloadsBuffer(height),

committer: committer,

Expand Down Expand Up @@ -329,17 +329,12 @@ func (s *GossipStateProviderImpl) antiEntropy() {
}
}
}
s.logger.Debug("[XXX]: Stateprovider stopped, stoping anti entropy procedure.")

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

if current > 0 {
current = current + 1
}
//s.logger.Debugf("Requesting new blocks in range [%d...%d].", current+1, max)
s.requestBlocksInRange(uint64(current), uint64(max))
}
s.logger.Debug("[XXX]: Stateprovider stopped, stoping anti entropy procedure.")
Expand Down
9 changes: 6 additions & 3 deletions gossip/state/state_test.go
Expand Up @@ -25,6 +25,7 @@ import (
"time"

pb "github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/common/configtx/test"
"github.com/hyperledger/fabric/common/util"
"github.com/hyperledger/fabric/core/committer"
"github.com/hyperledger/fabric/core/ledger/ledgermgmt"
Expand Down Expand Up @@ -123,7 +124,7 @@ func (*naiveCryptoService) ValidateIdentity(peerIdentity api.PeerIdentityType) e
func bootPeers(ids ...int) []string {
peers := []string{}
for _, id := range ids {
peers = append(peers, fmt.Sprintf("localhost:%d", (id+portPrefix)))
peers = append(peers, fmt.Sprintf("localhost:%d", id+portPrefix))
}
return peers
}
Expand Down Expand Up @@ -172,6 +173,8 @@ func newGossipInstance(config *gossip.Config) gossip.Gossip {
// Create new instance of KVLedger to be used for testing
func newCommitter(id int) committer.Committer {
ledger, _ := ledgermgmt.CreateLedger(strconv.Itoa(id))
cb, _ := test.MakeGenesisBlock(util.GetTestChainID())
ledger.Commit(cb)
return committer.NewLedgerCommitter(ledger, &validator.MockValidator{})
}

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

0 comments on commit 5a8973d

Please sign in to comment.