Skip to content

Commit

Permalink
Merge "FAB-854 Removed old peer pkg, moved peernext->peer"
Browse files Browse the repository at this point in the history
  • Loading branch information
Srinivasan Muralidharan authored and Gerrit Code Review committed Oct 26, 2016
2 parents 021b3c4 + eefe40b commit 40d9afb
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 4,475 deletions.
2 changes: 1 addition & 1 deletion core/devops.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/hyperledger/fabric/core/chaincode/platforms"
"github.com/hyperledger/fabric/core/container"
crypto "github.com/hyperledger/fabric/core/crypto"
"github.com/hyperledger/fabric/core/peernext"
"github.com/hyperledger/fabric/core/peer"
"github.com/hyperledger/fabric/core/util"
pb "github.com/hyperledger/fabric/protos"
)
Expand Down
2 changes: 1 addition & 1 deletion core/endorser/endorser.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/hyperledger/fabric/core/chaincode"
ledger "github.com/hyperledger/fabric/core/ledgernext"
"github.com/hyperledger/fabric/core/ledgernext/kvledger"
"github.com/hyperledger/fabric/core/peernext"
"github.com/hyperledger/fabric/core/peer"
"github.com/hyperledger/fabric/core/util"
pb "github.com/hyperledger/fabric/protos"
)
Expand Down
File renamed without changes.
449 changes: 15 additions & 434 deletions core/peer/handler.go

Large diffs are not rendered by default.

121 changes: 0 additions & 121 deletions core/peer/handler_sync_state.go

This file was deleted.

51 changes: 11 additions & 40 deletions core/peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,6 @@ type Peer interface {
NewOpenchainDiscoveryHello() (*pb.Message, error)
}

// BlocksRetriever interface for retrieving blocks .
type BlocksRetriever interface {
RequestBlocks(*pb.SyncBlockRange) (<-chan *pb.SyncBlocks, error)
}

// StateRetriever interface for retrieving state deltas, etc.
type StateRetriever interface {
RequestStateSnapshot() (<-chan *pb.SyncStateSnapshot, error)
RequestStateDeltas(syncBlockRange *pb.SyncBlockRange) (<-chan *pb.SyncStateDeltas, error)
}

// RemoteLedger interface for retrieving remote ledger data.
type RemoteLedger interface {
BlocksRetriever
StateRetriever
}

// BlockChainAccessor interface for retreiving blocks by block number
type BlockChainAccessor interface {
GetBlockByNumber(blockNumber uint64) (*pb.Block, error)
Expand Down Expand Up @@ -97,7 +80,6 @@ type StateAccessor interface {

// MessageHandler standard interface for handling Openchain messages.
type MessageHandler interface {
RemoteLedger
HandleMessage(msg *pb.Message) error
SendMessage(msg *pb.Message) error
To() (pb.PeerEndpoint, error)
Expand All @@ -117,7 +99,6 @@ type MessageHandlerCoordinator interface {
Broadcast(*pb.Message, pb.PeerEndpoint_Type) []error
Unicast(*pb.Message, *pb.PeerID) error
GetPeers() (*pb.PeersMessage, error)
GetRemoteLedger(receiver *pb.PeerID) (RemoteLedger, error)
PeersDiscovered(*pb.PeersMessage) error
ExecuteTransaction(transaction *pb.Transaction) *pb.Response
Discoverer
Expand Down Expand Up @@ -177,7 +158,7 @@ type handlerMap struct {
}

// HandlerFactory for creating new MessageHandlers
type HandlerFactory func(MessageHandlerCoordinator, ChatStream, bool) (MessageHandler, error)
type HandlerFactory func(MessageHandlerCoordinator, ChatStream, bool, MessageHandler) (MessageHandler, error)

// EngineFactory for creating new engines
type EngineFactory func(MessageHandlerCoordinator) (Engine, error)
Expand Down Expand Up @@ -321,17 +302,6 @@ func getPeerAddresses(peersMsg *pb.PeersMessage) []string {
return addresses
}

// GetRemoteLedger returns the RemoteLedger interface for the remote Peer Endpoint
func (p *Impl) GetRemoteLedger(receiverHandle *pb.PeerID) (RemoteLedger, error) {
p.handlerMap.RLock()
defer p.handlerMap.RUnlock()
remoteLedger, ok := p.handlerMap.m[*receiverHandle]
if !ok {
return nil, fmt.Errorf("Remote ledger not found for receiver %s", receiverHandle.Name)
}
return remoteLedger, nil
}

// PeersDiscovered used by MessageHandlers for notifying this coordinator of discovered PeerEndoints. May include this Peer's PeerEndpoint.
func (p *Impl) PeersDiscovered(peersMessage *pb.PeersMessage) error {
thisPeersEndpoint, err := GetPeerEndpoint()
Expand Down Expand Up @@ -593,7 +563,7 @@ func (p *Impl) chatWithPeer(address string) error {
func (p *Impl) handleChat(ctx context.Context, stream ChatStream, initiatedStream bool) error {
deadline, ok := ctx.Deadline()
peerLogger.Debugf("Current context deadline = %s, ok = %v", deadline, ok)
handler, err := p.handlerFactory(p, stream, initiatedStream)
handler, err := p.handlerFactory(p, stream, initiatedStream, nil)
if err != nil {
return fmt.Errorf("Error creating handler during handleChat initiation: %s", err)
}
Expand Down Expand Up @@ -643,14 +613,15 @@ func (p *Impl) newHelloMessage() (*pb.HelloMessage, error) {
if err != nil {
return nil, fmt.Errorf("Error creating hello message: %s", err)
}
p.ledgerWrapper.RLock()
defer p.ledgerWrapper.RUnlock()
//size := p.ledgerWrapper.ledger.GetBlockchainSize()
blockChainInfo, err := p.ledgerWrapper.ledger.GetBlockchainInfo()
if err != nil {
return nil, fmt.Errorf("Error creating hello message, error getting block chain info: %s", err)
}
return &pb.HelloMessage{PeerEndpoint: endpoint, BlockchainInfo: blockChainInfo}, nil
//p.ledgerWrapper.RLock()
//defer p.ledgerWrapper.RUnlock()
////size := p.ledgerWrapper.ledger.GetBlockchainSize()
//blockChainInfo, err := p.ledgerWrapper.ledger.GetBlockchainInfo()
//if err != nil {
// return nil, fmt.Errorf("Error creating hello message, error getting block chain info: %s", err)
//}
//return &pb.HelloMessage{PeerEndpoint: endpoint, BlockchainInfo: blockChainInfo}, nil
return &pb.HelloMessage{PeerEndpoint: endpoint}, nil
}

// GetBlockByNumber return a block by block number
Expand Down
Loading

0 comments on commit 40d9afb

Please sign in to comment.