diff --git a/core/committer/committer_impl.go b/core/committer/committer_impl.go index 34bd520c964..514964a690b 100644 --- a/core/committer/committer_impl.go +++ b/core/committer/committer_impl.go @@ -17,8 +17,11 @@ limitations under the License. package committer import ( + "fmt" + "github.com/hyperledger/fabric/core/committer/txvalidator" "github.com/hyperledger/fabric/core/ledger" + "github.com/hyperledger/fabric/events/producer" "github.com/hyperledger/fabric/protos/common" pb "github.com/hyperledger/fabric/protos/peer" "github.com/op/go-logging" @@ -60,6 +63,13 @@ func (lc *LedgerCommitter) Commit(block *common.Block) error { if err := lc.ledger.Commit(block); err != nil { return err } + + // send block event *after* the block has been committed + if err := producer.SendProducerBlockEvent(block); err != nil { + logger.Errorf("Error sending block event %s", err) + return fmt.Errorf("Error sending block event %s", err) + } + return nil } diff --git a/core/deliverservice/client.go b/core/deliverservice/client.go index fcbcef2932d..5c601ee8f0e 100644 --- a/core/deliverservice/client.go +++ b/core/deliverservice/client.go @@ -22,7 +22,6 @@ import ( "github.com/golang/protobuf/proto" "github.com/hyperledger/fabric/core/committer" - "github.com/hyperledger/fabric/events/producer" gossipcommon "github.com/hyperledger/fabric/gossip/common" gossip_proto "github.com/hyperledger/fabric/gossip/proto" "github.com/hyperledger/fabric/gossip/service" @@ -219,10 +218,6 @@ func (d *DeliverService) readUntilClose() { // Gossip messages with other nodes logger.Debugf("Gossiping block [%d], peers number [%d]", seqNum, numberOfPeers) service.GetGossipService().Gossip(gossipMsg) - if err = producer.SendProducerBlockEvent(t.Block); err != nil { - logger.Errorf("Error sending block event %s", err) - } - default: logger.Warning("Received unknown: ", t) return