- java.lang.Object
-
- io.hotmoka.local.AbstractStore<C>
-
- 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 Summary
Fields Modifier and Type Field Description protected CconfigThe configuration ofnode.protected ObjectlockThe lock for modifications of the store.protected static org.slf4j.Loggerloggerprotected AbstractLocalNode<? extends C,? extends AbstractStore<? extends C>>nodeThe node having this store.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractStore(AbstractLocalNode<? extends C,? extends AbstractStore<? extends C>> node)Builds the store for a node.protectedAbstractStore(AbstractStore<? extends C> parent)Builds a clone of the given store.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()voidpush(TransactionReference reference, TransactionRequest<?> request, TransactionResponse response)Pushes into the store the result of executing a successful Hotmoka request.protected voidrecordTime(Runnable task)Executes the given task, taking note of the time required for it.protected <T> TrecordTime(Supplier<T> task)Executes the given task, taking note of the time required for it.protected <T> TrecordTimeSynchronized(Supplier<T> task)Executes the given task, taking note of the time required for it, inside a synchronized block onlock.voidreplace(TransactionReference reference, TransactionRequest<?> request, TransactionResponse response)Pushes into the store the result of executing a successful Hotmoka request.protected abstract voidsetHistory(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).protected abstract voidsetManifest(StorageReference manifest)Mark the node as initialized.protected abstract voidsetResponse(TransactionReference reference, TransactionRequest<?> request, TransactionResponse response)Writes in store the given request and response for the given transaction reference.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.hotmoka.local.Store
getError, getHistory, getHistoryUncommitted, getManifest, getManifestUncommitted, getNow, getRequest, getResponse, getResponseUncommitted, push
-
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
lock
protected final Object lock
The lock for modifications of the store.
-
node
protected final AbstractLocalNode<? extends C extends Config,? extends AbstractStore<? extends C extends Config>> node
The node having this store.
-
-
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
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable
-
push
public final void push(TransactionReference reference, TransactionRequest<?> request, TransactionResponse response)
Description copied from interface:StorePushes 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.
-
replace
public final void replace(TransactionReference reference, TransactionRequest<?> request, TransactionResponse response)
Description copied from interface:StorePushes into the store the result of executing a successful Hotmoka request. This method assumes that the given request was already present in the store.
-
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 transactionrequest- the requestresponse- 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 sethistory- 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
-
-