class Raft::PersistentState
Attributes
current_term[R]
log[R]
voted_for[R]
Public Class Methods
new()
click to toggle source
# File lib/raft.rb, line 51 def initialize @current_term = 0 @voted_for = nil @log = Log.new([]) end
Public Instance Methods
current_term=(new_term)
click to toggle source
# File lib/raft.rb, line 57 def current_term=(new_term) raise 'cannot restart an old term' unless @current_term < new_term @current_term = new_term @voted_for = nil end
log=(new_log)
click to toggle source
# File lib/raft.rb, line 68 def log=(new_log) @log = Log.new(new_log) end
voted_for=(new_votee)
click to toggle source
# File lib/raft.rb, line 63 def voted_for=(new_votee) raise 'cannot change vote for this term' unless @voted_for.nil? @voted_for = new_votee end