func (handler *ConsensusHandler) RequestBlocks(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error) {
	return handler.peerHandler.RequestBlocks(syncBlockRange)
}
RequestBlocks returns the current sync block
package helper
import (
	"fmt"
	"github.com/golang/protobuf/proto"
	"github.com/op/go-logging"
	"golang.org/x/net/context"
	"github.com/openblockchain/obc-peer/openchain/chaincode"
	"github.com/openblockchain/obc-peer/openchain/consensus"
	"github.com/openblockchain/obc-peer/openchain/consensus/controller"
	"github.com/openblockchain/obc-peer/openchain/peer"
	pb "github.com/openblockchain/obc-peer/protos"
)
var logger *logging.Logger  
func init() {
	logger = logging.MustGetLogger("consensus/handler")
}
type ConsensusHandler struct {
	consenter   consensus.Consenter
	coordinator peer.MessageHandlerCoordinator
	peerHandler peer.MessageHandler
}
func NewConsensusHandler(coord peer.MessageHandlerCoordinator,
	stream peer.ChatStream, initiatedStream bool,
	next peer.MessageHandler) (peer.MessageHandler, error) {
	handler := &ConsensusHandler{
		coordinator: coord,
		peerHandler: next,
	}
	var err error
	handler.peerHandler, err = peer.NewPeerHandler(coord, stream, initiatedStream, nil)
	if err != nil {
		return nil, fmt.Errorf("Error creating PeerHandler: %s", err)
	}
	handler.consenter = controller.NewConsenter(NewHelper(coord))
	return handler, nil
}
func (handler *ConsensusHandler) HandleMessage(msg *pb.OpenchainMessage) error {
	if msg.Type == pb.OpenchainMessage_CONSENSUS {
		senderPE, _ := handler.peerHandler.To()
		return handler.consenter.RecvMsg(msg, senderPE.ID)
	}
	if msg.Type == pb.OpenchainMessage_CHAIN_TRANSACTION {
		return handler.doChainTransaction(msg)
	}
	if msg.Type == pb.OpenchainMessage_CHAIN_QUERY {
		return handler.doChainQuery(msg)
	}
	if logger.IsEnabledFor(logging.DEBUG) {
		logger.Debug("Did not handle message of type %s, passing on to next MessageHandler", msg.Type)
	}
	return handler.peerHandler.HandleMessage(msg)
}
func (handler *ConsensusHandler) doChainTransaction(msg *pb.OpenchainMessage) error {
	var response *pb.Response
	tx := &pb.Transaction{}
	err := proto.Unmarshal(msg.Payload, tx)
	if err != nil {
		response = &pb.Response{Status: pb.Response_FAILURE,
			Msg: []byte(fmt.Sprintf("Error unmarshalling payload OpenchainMessage:%s.", msg.Type))}
	} else {
		secHelper := handler.coordinator.GetSecHelper()
		if nil != secHelper {
			if logger.IsEnabledFor(logging.DEBUG) {
				logger.Debug("Verifying transaction signature %s", tx.Uuid)
			}
			if tx, err = secHelper.TransactionPreValidation(tx); nil != err {
				response = &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(err.Error())}
				logger.Debug("Failed to verify transaction %v", err)
			}
		}
	}
	if nil == response {
		response = &pb.Response{Status: pb.Response_SUCCESS, Msg: []byte(tx.Uuid)}
	}
	payload, err := proto.Marshal(response)
	handler.SendMessage(&pb.OpenchainMessage{Type: pb.OpenchainMessage_RESPONSE, Payload: payload})
	if response.Status == pb.Response_FAILURE {
		return nil
	}
	selfPE, _ := handler.coordinator.GetPeerEndpoint()  
	return handler.consenter.RecvMsg(msg, selfPE.ID)
}
func (handler *ConsensusHandler) doChainQuery(msg *pb.OpenchainMessage) error {
	var response *pb.Response
	tx := &pb.Transaction{}
	err := proto.Unmarshal(msg.Payload, tx)
	if err != nil {
		response = &pb.Response{Status: pb.Response_FAILURE,
			Msg: []byte(fmt.Sprintf("Error unmarshalling payload of received OpenchainMessage:%s.", msg.Type))}
	} else {
		secHelper := handler.coordinator.GetSecHelper()
		if nil != secHelper {
			if logger.IsEnabledFor(logging.DEBUG) {
				logger.Debug("Verifying transaction signature %s", tx.Uuid)
			}
			if tx, err = secHelper.TransactionPreValidation(tx); nil != err {
				response = &pb.Response{Status: pb.Response_FAILURE, Msg: []byte(err.Error())}
				logger.Debug("Failed to verify transaction %v", err)
			}
		}
		if nil == response {
			cxt := context.Background()
			result, err := chaincode.Execute(cxt, chaincode.GetChain(chaincode.DefaultChain), tx)
			if err != nil {
				response = &pb.Response{Status: pb.Response_FAILURE,
					Msg: []byte(fmt.Sprintf("Error:%s", err))}
			} else {
				response = &pb.Response{Status: pb.Response_SUCCESS, Msg: result}
			}
		}
	}
	payload, _ := proto.Marshal(response)
	handler.SendMessage(&pb.OpenchainMessage{Type: pb.OpenchainMessage_RESPONSE, Payload: payload})
	return nil
}
func (handler *ConsensusHandler) SendMessage(msg *pb.OpenchainMessage) error {
	logger.Debug("Sending to stream a message of type: %s", msg.Type)
	err := handler.peerHandler.SendMessage(msg)
	if err != nil {
		return fmt.Errorf("Error sending message through ChatStream: %s", err)
	}
	return nil
}
func (handler *ConsensusHandler) Stop() error {
	err := handler.peerHandler.Stop()  
	if err != nil {
		return fmt.Errorf("Error stopping ConsensusHandler: %s", err)
	}
	return nil
}
func (handler *ConsensusHandler) To() (pb.PeerEndpoint, error) {
	return handler.peerHandler.To()
}