Class: Universa::ChainStore

Inherits:
Object
  • Object
show all
Defined in:
lib/universa/chain_store.rb

Overview

Work iun progress, not to use as for now.

The storage interface capable to store contracts in chains, providing search and attributes. This class is not a store itself but the base class for it, having common boilerplate and sort of interface to implement. _Under development, we might change it_

Direct Known Subclasses

FSStore::FileStore

Instance Method Summary collapse

Instance Method Details

#<<(contract) ⇒ ChainStore

Same as #store_contract but returns store

Parameters:

Returns:



24
25
26
27
# File 'lib/universa/chain_store.rb', line 24

def <<(contract)
  store_contract(contract)
  self
end

#countObject

Count contracts in the store. This operation could be slow.

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/universa/chain_store.rb', line 36

def count
  raise NotImplementedError
end

#find_by_id(hash_id) ⇒ Contract

Returns with the corresponding id or nil.

Parameters:

  • hash_id (HashId)

    instance to look for

Returns:

  • (Contract)

    with the corresponding id or nil

Raises:

  • (NotImplementedError)


31
32
33
# File 'lib/universa/chain_store.rb', line 31

def find_by_id(hash_id)
  raise NotImplementedError
end

#find_by_id!(hash_id) ⇒ Contract

Returns with the corresponding id or raise.

Parameters:

  • hash_id (HashId)

    instance to look for

Returns:

  • (Contract)

    with the corresponding id or raise.

Raises:



43
44
45
# File 'lib/universa/chain_store.rb', line 43

def find_by_id! hash_id
  find_by_id(hash_id) or raise NotFoundError
end

#find_by_parent(hash_id) ⇒ Array

Find all contracts with this parent id.

Parameters:

  • hash_id (HashId)

    of the parent contract

Returns:

  • (Array)

    all the contracts that match this criterion

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/universa/chain_store.rb', line 50

def find_by_parent(hash_id)
  raise NotImplementedError
end

#store_contract(contract) ⇒ StoredContract

Save contract to the store. When this method returns, the contract must me already stored. If the contract with such hasId is already stored, just returns it.

Parameters:

  • contract (Object)

    to store

Returns:

  • (StoredContract)

    for this contract

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/universa/chain_store.rb', line 17

def store_contract(contract)
  raise NotImplementedError
end