Skip to content

Commit 39a1dce

Browse files
committed
FAB-1065 Gossip leader election scaffolding
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 <[email protected]>
1 parent af5285a commit 39a1dce

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

gossip/election/election.go

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright IBM Corp. 2016 All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package election
18+
19+
import (
20+
"github.com/hyperledger/fabric/gossip/common"
21+
"github.com/hyperledger/fabric/gossip/proto"
22+
)
23+
24+
// LeaderElectionAdapter is used by the leader election module
25+
// to send and receive messages, as well as notify a leader change
26+
type LeaderElectionAdapter interface {
27+
28+
// Gossip gossips a message to other peers
29+
Gossip(msg *proto.GossipMessage)
30+
31+
// Accept returns a channel that emits messages that fit
32+
// the given predicate
33+
Accept(common.MessageAcceptor) <-chan *proto.GossipMessage
34+
}
35+
36+
// LeaderElectionService is the object that runs the leader election algorithm
37+
type LeaderElectionService interface {
38+
// IsLeader returns whether this peer is a leader or not
39+
IsLeader() bool
40+
}
41+
42+
// LeaderElectionService is the implementation of LeaderElectionService
43+
type leaderElectionServiceImpl struct {
44+
adapter LeaderElectionAdapter
45+
}

0 commit comments

Comments
 (0)