Skip to content

Commit

Permalink
FAB-1065 Gossip leader election scaffolding
Browse files Browse the repository at this point in the history
This commit is a scaffolding for a to-be implemented
leader election module that is going to be used for peers
of a same organization to all agree on a single peer
that will connect to the ordering service

https://jira.hyperledger.org/browse/FAB-1065

Change-Id: I1dd04aad05a7cd524c2ef1d6dd55daa537eaa68a
Signed-off-by: Yacov Manevich <yacovm@il.ibm.com>
  • Loading branch information
yacovm committed Nov 17, 2016
1 parent af5285a commit 39a1dce
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions gossip/election/election.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright IBM Corp. 2016 All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package election

import (
"github.com/hyperledger/fabric/gossip/common"
"github.com/hyperledger/fabric/gossip/proto"
)

// LeaderElectionAdapter is used by the leader election module
// to send and receive messages, as well as notify a leader change
type LeaderElectionAdapter interface {

// Gossip gossips a message to other peers
Gossip(msg *proto.GossipMessage)

// Accept returns a channel that emits messages that fit
// the given predicate
Accept(common.MessageAcceptor) <-chan *proto.GossipMessage
}

// LeaderElectionService is the object that runs the leader election algorithm
type LeaderElectionService interface {
// IsLeader returns whether this peer is a leader or not
IsLeader() bool
}

// LeaderElectionService is the implementation of LeaderElectionService
type leaderElectionServiceImpl struct {
adapter LeaderElectionAdapter
}

0 comments on commit 39a1dce

Please sign in to comment.