Browse Source

add HasLeader function

Xiang Li 11 years ago
parent
commit
584186c7ff
1 changed files with 2 additions and 0 deletions
  1. 2 0
      raft/node.go

+ 2 - 0
raft/node.go

@@ -47,6 +47,8 @@ func Dictate(n *Node) *Node {
 
 
 func (n *Node) Id() int { return n.sm.id }
 func (n *Node) Id() int { return n.sm.id }
 
 
+func (n *Node) HasLeader() bool { return n.sm.lead != none }
+
 // Propose asynchronously proposes data be applied to the underlying state machine.
 // Propose asynchronously proposes data be applied to the underlying state machine.
 func (n *Node) Propose(data []byte) { n.propose(normal, data) }
 func (n *Node) Propose(data []byte) { n.propose(normal, data) }