diff --git a/core/peer/peer.go b/core/peer/peer.go index 0179e8ea028..4c0ae33ab72 100644 --- a/core/peer/peer.go +++ b/core/peer/peer.go @@ -212,6 +212,10 @@ func CreateChainFromBlock(cb *common.Block) error { return err } + if err := ledger.Commit(cb); err != nil { + peerLogger.Errorf("Unable to get genesis block committed into the ledger, chainID %v", cid) + return err + } return createChain(cid, ledger, cb) } diff --git a/gossip/state/state.go b/gossip/state/state.go index b6c6b497f85..03d2fc91ea4 100644 --- a/gossip/state/state.go +++ b/gossip/state/state.go @@ -112,13 +112,6 @@ func NewGossipStateProvider(chainID string, g gossip.Gossip, committer committer return nil } - //if the ledger is empty, we need a block from orderer - //so don't expect height+1 but expect 0 - next := height - if height > 0 { - next = height + 1 - } - s := &GossipStateProviderImpl{ chainID: chainID, @@ -133,7 +126,7 @@ func NewGossipStateProvider(chainID string, g gossip.Gossip, committer committer stopFlag: 0, // Create a queue for payload received - payloads: NewPayloadsBuffer(next), + payloads: NewPayloadsBuffer(height + 1), committer: committer, diff --git a/gossip/state/state_test.go b/gossip/state/state_test.go index d25794fdcb7..7443cda6979 100644 --- a/gossip/state/state_test.go +++ b/gossip/state/state_test.go @@ -294,7 +294,7 @@ func TestNewGossipStateProvider_SendingManyMessages(t *testing.T) { msgCount := 10 - for i := 0; i < msgCount; i++ { + for i := 1; i <= msgCount; i++ { rawblock := pcomm.NewBlock(uint64(i), []byte{}) if bytes, err := pb.Marshal(rawblock); err == nil { payload := &proto.Payload{uint64(i), "", bytes}