From ebe1b4d3490bf64135088c2d01af9cf8fdf20458 Mon Sep 17 00:00:00 2001 From: Artem Barger Date: Fri, 3 Mar 2017 23:32:21 +0200 Subject: [PATCH] [FAB-FAB-2634]: Send event of genesis block committed. After new block is committed there is an event generated, the only exception currently is for genesis block. This commit produces event after peer joins the channel and creates it for the first time. Change-Id: I99ee9f8f8a7234445517c272f9e80617f176fe56 Signed-off-by: Artem Barger --- core/peer/peer.go | 1 + core/scc/cscc/configure.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/core/peer/peer.go b/core/peer/peer.go index 7471d33c40e..de8848f5fa8 100644 --- a/core/peer/peer.go +++ b/core/peer/peer.go @@ -231,6 +231,7 @@ func CreateChainFromBlock(cb *common.Block) error { peerLogger.Errorf("Unable to get genesis block committed into the ledger, chainID %v", cid) return err } + return createChain(cid, ledger, cb) } diff --git a/core/scc/cscc/configure.go b/core/scc/cscc/configure.go index 0bf3f342665..99e90b716b1 100644 --- a/core/scc/cscc/configure.go +++ b/core/scc/cscc/configure.go @@ -27,6 +27,7 @@ import ( "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/core/chaincode/shim" "github.com/hyperledger/fabric/core/peer" + "github.com/hyperledger/fabric/events/producer" pb "github.com/hyperledger/fabric/protos/peer" "github.com/hyperledger/fabric/protos/utils" "github.com/op/go-logging" @@ -120,6 +121,11 @@ func joinChain(blockBytes []byte) pb.Response { peer.InitChain(chainID) + if err := producer.SendProducerBlockEvent(block); err != nil { + msg := fmt.Sprintf("Error sending block event %s", err) + return shim.Error(msg) + } + return shim.Success(nil) }