Skip to content

Commit

Permalink
[FAB-1862] - send block event after commit
Browse files Browse the repository at this point in the history
This change set ensures that block events are generated only *after* the
block has been committed to the ledger (and not before as it was the case
previously).

Change-Id: I25bab47cc7d69b6e804fc605cf7710dca0050d21
Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
  • Loading branch information
ale-linux committed Jan 27, 2017
1 parent 62eac5b commit acf3298
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 10 additions & 0 deletions core/committer/committer_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
5 changes: 0 additions & 5 deletions core/deliverservice/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit acf3298

Please sign in to comment.