Class AbstractStore<C extends Config>

  • All Implemented Interfaces:
    Store, AutoCloseable

    public abstract class AbstractStore<C extends Config>
    extends Object
    implements Store
    Shared implementation of the store of a node. It keeps information about the state of the objects created by the requests executed by the node. This store is external to the node and, typically, only its hash is stored in the node, if consensus is needed.
    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
      • lock

        protected final Object lock
        The lock for modifications of the store.
      • config

        protected final C extends Config config
        The configuration of node.
    • Constructor Detail

      • AbstractStore

        protected AbstractStore​(AbstractLocalNode<? extends C,​? extends AbstractStore<? extends C>> node)
        Builds the store for a node.
        Parameters:
        node - the node having this store
      • AbstractStore

        protected AbstractStore​(AbstractStore<? extends C> parent)
        Builds a clone of the given store.
        Parameters:
        parent - the store to clone
    • Method Detail

      • push

        public final void push​(TransactionReference reference,
                               TransactionRequest<?> request,
                               TransactionResponse response)
        Description copied from interface: Store
        Pushes into the store the result of executing a successful Hotmoka request. This method assumes that the given request was not already present in the store.
        Specified by:
        push in interface Store
        Parameters:
        reference - the reference of the request
        request - the request of the transaction
        response - the response of the transaction
      • replace

        public final void replace​(TransactionReference reference,
                                  TransactionRequest<?> request,
                                  TransactionResponse response)
        Description copied from interface: Store
        Pushes into the store the result of executing a successful Hotmoka request. This method assumes that the given request was already present in the store.
        Specified by:
        replace in interface Store
        Parameters:
        reference - the reference of the request
        request - the request of the transaction
        response - the response of the transaction
      • setResponse

        protected abstract void setResponse​(TransactionReference reference,
                                            TransactionRequest<?> request,
                                            TransactionResponse response)
        Writes in store the given request and response for the given transaction reference.
        Parameters:
        reference - the reference of the transaction
        request - the request
        response - the response
      • setHistory

        protected abstract void setHistory​(StorageReference object,
                                           Stream<TransactionReference> history)
        Sets the history of the given object, that is, the references to the transactions that provide information about its current state, in reverse chronological order (from newest to oldest).
        Parameters:
        object - the object whose history is set
        history - the stream that will become the history of the object, replacing its previous history; this is in chronological order, from newest transactions to oldest; hence the last transaction is that when the object has been created
      • setManifest

        protected abstract void setManifest​(StorageReference manifest)
        Mark the node as initialized. This happens for initialization requests.
        Parameters:
        manifest - the manifest to put in the node
      • recordTime

        protected final void recordTime​(Runnable task)
        Executes the given task, taking note of the time required for it.
        Parameters:
        task - the task
      • recordTime

        protected final <T> T recordTime​(Supplier<T> task)
        Executes the given task, taking note of the time required for it.
        Parameters:
        task - the task
      • recordTimeSynchronized

        protected final <T> T recordTimeSynchronized​(Supplier<T> task)
        Executes the given task, taking note of the time required for it, inside a synchronized block on lock.
        Parameters:
        task - the task