class Zold::NoDupEntrance
The entrance that ignores dups
Public Class Methods
new(entrance, wallets, log: Log::NULL)
click to toggle source
# File lib/zold/node/nodup_entrance.rb, line 36 def initialize(entrance, wallets, log: Log::NULL) @entrance = entrance @wallets = wallets @log = log end
Public Instance Methods
push(id, body)
click to toggle source
Returns a list of modifed wallets (as Zold::Id
)
# File lib/zold/node/nodup_entrance.rb, line 52 def push(id, body) before = @wallets.acq(id) { |w| w.exists? ? w.digest : '' } after = OpenSSL::Digest::SHA256.new(body).hexdigest if before == after @log.debug("Duplicate of #{id} ignored #{Size.new(body.length)}") return [] end @log.debug("New content for #{id} arrived #{Size.new(body.length)}") @entrance.push(id, body) end
start() { |self| ... }
click to toggle source
# File lib/zold/node/nodup_entrance.rb, line 42 def start raise 'Block must be given to start()' unless block_given? @entrance.start { yield(self) } end
to_json()
click to toggle source
# File lib/zold/node/nodup_entrance.rb, line 47 def to_json @entrance.to_json end