diff --git a/src/crystal-scatter/metaring.cr b/src/crystal-scatter/metaring.cr index a6832e5..18898ae 100644 --- a/src/crystal-scatter/metaring.cr +++ b/src/crystal-scatter/metaring.cr @@ -44,8 +44,11 @@ module Crystal::Scatter return tag end - private def get_slice_from_hash(h : UInt64) - + private def get_slice_from_hash(ring : Ring, h : UInt64) + value = ring.find do |slice| + h>=slice.s_begin && slice.s_end>=h + end + return value.not_nil! end def add(element : Daemon) @@ -84,10 +87,7 @@ module Crystal::Scatter end slices = Array(Slice).new targets.each do |h| - value = ring.find do |slice| - h>=slice.s_begin && slice.s_end>=h - end - slices << value.not_nil! + slices << get_slice_from_hash(ring, h) end return slices end