lib/sp_store/p_chip/soft_node_cache.rb
# Instantiates a software model of the P chip's node cache module.
Instantiates a software model of the P chip's node cache module.
Instantiates a software model of the P chip ' s node cache module .
def load(cache_entry, node_id, node_hash, old_parent_entry)
    check_entry cache_entry
    if node_id <= 1 || node_id >= 2 * @leaf_count
      raise ArgumentError, "Invalid node id #{node_id.inspect}"
    end
    if @verified[cache_entry]
      check_entry old_parent_entry
      if @left_child[cache_entry] or @right_child[cache_entry]
        raise RuntimeError, "The entry's node has at least one child cached"
      end
      old_node_id = @node_ids[cache_entry]
      if @node_ids[old_parent_entry] != Helpers.parent(old_node_id)
        raise RuntimeError, 'Parent node not found at old_parent_entry'
      end
      if Helpers.left_child?(old_node_id)
        @left_child[old_parent_entry] = false
      else
        @right_child[old_parent_entry] = false
      end
    end
    @node_ids[cache_entry] = node_id
    @verified[cache_entry] = false
    @node_hashes[cache_entry] = node_hash
    @left_child[cache_entry] = @right_child[cache_entry] = false
  end
def load ( cache_entry , node_id , node_hash , old_parent_entry ) check_entry cache_entry if node_id <= 1 || node_id >= 2 * @leaf_count raise ArgumentError , "Invalid node id #{node_id.inspect}" end if @verified [ cache_entry ] check_entry old_parent_entry if @left_child [ cache_entry ] or @right_child [ cache_entry ] raise RuntimeError , "The entry's node has at least one child cached" end old_node_id = @node_ids [ cache_entry ] if @node_ids [ old_parent_entry ] != Helpers . parent ( old_node_id ) raise RuntimeError , 'Parent node not found at old_parent_entry' end if Helpers . left_child? ( old_node_id ) @left_child [ old_parent_entry ] = false else @right_child [ old_parent_entry ] = false end end @node_ids [ cache_entry ] = node_id @verified [ cache_entry ] = false @node_hashes [ cache_entry ] = node_hash @left_child [ cache_entry ] = @right_child [ cache_entry ] = false end
Instantiates a software model of the P chip's node cache module.
Instantiates a software model of the P chip ' s node cache module .
cache_entry
node_id
node_hash
old_parent_entry