()
| 62 | } |
| 63 | |
| 64 | func (n *node) AmLeader() bool { |
| 65 | // Return false if the node is not the leader. Otherwise, check the lastQuorum as well. |
| 66 | if !n.amLeader() { |
| 67 | return false |
| 68 | } |
| 69 | // This node must be the leader, but must also be an active member of |
| 70 | // the cluster, and not hidden behind a partition. Basically, if this |
| 71 | // node was the leader and goes behind a partition, it would still |
| 72 | // think that it is indeed the leader for the duration mentioned below. |
| 73 | n.mu.RLock() |
| 74 | defer n.mu.RUnlock() |
| 75 | return time.Since(n.lastQuorum) <= 5*time.Second |
| 76 | } |
| 77 | |
| 78 | // {2 bytes Node ID} {4 bytes for random} {2 bytes zero} |
| 79 | func (n *node) initProposalKey(id uint64) error { |
no test coverage detected