Skip to content

Commit

Permalink
Simplified the generic types of the stores, store transactions and nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
spoto committed May 9, 2024
1 parent 2aa2d42 commit 05b6b26
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* nor transactions. Updates are stored in files, rather than in an external database.
*/
@ThreadSafe
public class DiskNodeImpl extends AbstractLocalNode<DiskNodeImpl, DiskNodeConfig, DiskStore> implements DiskNode {
public class DiskNodeImpl extends AbstractLocalNode<DiskNodeConfig, DiskStore> implements DiskNode {

/**
* The mempool where transaction requests are stored and eventually executed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* while the histories are kept in RAM.
*/
@Immutable
class DiskStore extends AbstractStore<DiskStore, DiskNodeImpl> {
class DiskStore extends AbstractStore<DiskStore> {

/**
* The path where the database of the store gets created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* back and forth in time. Different moments of the store are identifies by state
* identifiers, that can be checked out when needed.
*/
public interface CheckableStore<S extends CheckableStore<S, N>, N extends LocalNode<?>> extends Store<S,N> {
public interface CheckableStore<S extends CheckableStore<S>> extends Store<S> {

/**
* Yields a unique identifier for the current state of this store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
* @param <S> the type of the store of the node
*/
@ThreadSafe
public interface LocalNode<C extends LocalNodeConfig<?,?>> extends Node {
public interface LocalNode<C extends LocalNodeConfig<C,?>> extends Node {
C getLocalConfig() throws NodeException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* be used concurrently for executing more requests.
*/
@ThreadSafe
public interface Store<S extends Store<S, N>, N extends LocalNode<?>> extends AutoCloseable {
public interface Store<S extends Store<S>> extends AutoCloseable {

/**
* Yields the response of the transaction having the given reference.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* its hash is held in the node, if consensus is needed. Stores must be thread-safe, since they can
* be used concurrently for executing more requests.
*/
public interface StoreTransaction<S extends Store<S, ?>> {
public interface StoreTransaction<S extends Store<S>> {

/**
* Yields the store from which this transaction begun.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @param <S> the type of the store of the node
*/
@ThreadSafe
public abstract class AbstractLocalNode<N extends AbstractLocalNode<N,C,S>, C extends LocalNodeConfig<?,?>, S extends AbstractStore<S, N>> extends AbstractLocalNodeImpl<N,C,S> {
public abstract class AbstractLocalNode<C extends LocalNodeConfig<C,?>, S extends AbstractStore<S>> extends AbstractLocalNodeImpl<C,S> {

/**
* Builds a node with a brand new, empty store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import io.hotmoka.node.local.api.StoreTransaction;

@Immutable
public abstract class AbstractStore<S extends AbstractStore<S, N>, N extends AbstractLocalNode<N, ?, S>> implements Store<S, N> {
public abstract class AbstractStore<S extends AbstractStore<S>> implements Store<S> {

/**
* Cached recent transactions whose requests that have had their signature checked.
Expand Down Expand Up @@ -92,7 +92,7 @@ protected AbstractStore(ExecutorService executors, ConsensusConfig<?,?> consensu
this.inflation = OptionalLong.empty();
}

protected AbstractStore(AbstractStore<S, N> toClone) {
protected AbstractStore(AbstractStore<S> toClone) {
this.executors = toClone.executors;
this.hasher = toClone.hasher;
this.checkedSignatures = toClone.checkedSignatures;
Expand All @@ -104,7 +104,7 @@ protected AbstractStore(AbstractStore<S, N> toClone) {
this.inflation = toClone.inflation;
}

protected AbstractStore(AbstractStore<S, N> toClone, LRUCache<TransactionReference, Boolean> checkedSignatures, LRUCache<TransactionReference, EngineClassLoader> classLoaders, ConsensusConfig<?,?> consensus, Optional<BigInteger> gasPrice, OptionalLong inflation) {
protected AbstractStore(AbstractStore<S> toClone, LRUCache<TransactionReference, Boolean> checkedSignatures, LRUCache<TransactionReference, EngineClassLoader> classLoaders, ConsensusConfig<?,?> consensus, Optional<BigInteger> gasPrice, OptionalLong inflation) {
this.executors = toClone.executors;
this.hasher = toClone.hasher;
this.checkedSignatures = checkedSignatures; //new LRUCache<>(checkedSignatures);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
* its hash is held in the node, if consensus is needed. Stores must be thread-safe, since they can
* be used concurrently for executing more requests.
*/
public abstract class AbstractStoreTransaction<S extends AbstractStore<S, ?>> implements StoreTransaction<S> {
public abstract class AbstractStoreTransaction<S extends AbstractStore<S>> implements StoreTransaction<S> {
private final static Logger LOGGER = Logger.getLogger(AbstractStoreTransaction.class.getName());
private final S store;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
* This class is meant to be subclassed by specifying where errors, requests and histories are kept.
*/
@Immutable
public abstract class AbstractTrieBasedStore<S extends AbstractTrieBasedStore<S, N>, N extends AbstractLocalNode<N, ?, S>> extends AbstractStore<S, N> {
public abstract class AbstractTrieBasedStore<S extends AbstractTrieBasedStore<S>> extends AbstractStore<S> {

/**
* The Xodus environment that holds the store.
Expand Down Expand Up @@ -202,7 +202,7 @@ protected AbstractTrieBasedStore(ExecutorService executors, ConsensusConfig<?,?>
}
}

protected AbstractTrieBasedStore(AbstractTrieBasedStore<S, N> toClone) {
protected AbstractTrieBasedStore(AbstractTrieBasedStore<S> toClone) {
super(toClone);

this.env = toClone.env;
Expand All @@ -218,7 +218,7 @@ protected AbstractTrieBasedStore(AbstractTrieBasedStore<S, N> toClone) {
this.rootOfRequests = toClone.rootOfRequests;
}

protected AbstractTrieBasedStore(AbstractTrieBasedStore<S, N> toClone, LRUCache<TransactionReference, Boolean> checkedSignatures, LRUCache<TransactionReference, EngineClassLoader> classLoaders, ConsensusConfig<?,?> consensus, Optional<BigInteger> gasPrice, OptionalLong inflation, Optional<byte[]> rootOfResponses, Optional<byte[]> rootOfInfo, Optional<byte[]> rootOfErrors, Optional<byte[]> rootOfHistories, Optional<byte[]> rootOfRequests) {
protected AbstractTrieBasedStore(AbstractTrieBasedStore<S> toClone, LRUCache<TransactionReference, Boolean> checkedSignatures, LRUCache<TransactionReference, EngineClassLoader> classLoaders, ConsensusConfig<?,?> consensus, Optional<BigInteger> gasPrice, OptionalLong inflation, Optional<byte[]> rootOfResponses, Optional<byte[]> rootOfInfo, Optional<byte[]> rootOfErrors, Optional<byte[]> rootOfHistories, Optional<byte[]> rootOfRequests) {
super(toClone, checkedSignatures, classLoaders, consensus, gasPrice, inflation);

this.env = toClone.env;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import io.hotmoka.xodus.ExodusException;
import io.hotmoka.xodus.env.Transaction;

public abstract class AbstractTrieBasedStoreTransaction<S extends AbstractTrieBasedStore<S, ?>> extends AbstractStoreTransaction<S> {
public abstract class AbstractTrieBasedStoreTransaction<S extends AbstractTrieBasedStore<S>> extends AbstractStoreTransaction<S> {

/**
* The Xodus transaction where the updates get recorded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
import io.hotmoka.node.api.updates.Update;
import io.hotmoka.node.api.values.StorageReference;
import io.hotmoka.node.api.values.StorageValue;
import io.hotmoka.node.local.AbstractLocalNode;
import io.hotmoka.node.local.AbstractStore;
import io.hotmoka.node.local.LRUCache;
import io.hotmoka.node.local.api.LocalNode;
Expand All @@ -94,7 +93,7 @@
* @param <S> the type of the store of the node
*/
@ThreadSafe
public abstract class AbstractLocalNodeImpl<N extends AbstractLocalNode<N,C,S>, C extends LocalNodeConfig<?,?>, S extends AbstractStore<S, N>> extends AbstractAutoCloseableWithLockAndOnCloseHandlers<ClosedNodeException> implements LocalNode<C> {
public abstract class AbstractLocalNodeImpl<C extends LocalNodeConfig<C,?>, S extends AbstractStore<S>> extends AbstractAutoCloseableWithLockAndOnCloseHandlers<ClosedNodeException> implements LocalNode<C> {

/**
* The manager of the subscriptions to the events occurring in this node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* its state in a transactional database implemented by the {@link TendermintStore} class.
*/
@ThreadSafe
public class TendermintNodeImpl extends AbstractLocalNode<TendermintNodeImpl, TendermintNodeConfig, TendermintStore> implements TendermintNode {
public class TendermintNodeImpl extends AbstractLocalNode<TendermintNodeConfig, TendermintStore> implements TendermintNode {

private final static Logger LOGGER = Logger.getLogger(TendermintNodeImpl.class.getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* Tendermint, since it keeps such information inside its blocks.
*/
@Immutable
public class TendermintStore extends AbstractTrieBasedStore<TendermintStore, TendermintNodeImpl> {
public class TendermintStore extends AbstractTrieBasedStore<TendermintStore> {

/**
* The hasher used to merge the hashes of the many tries.
Expand Down

0 comments on commit 05b6b26

Please sign in to comment.