Skip to content
This repository was archived by the owner on Aug 23, 2020. It is now read-only.

Transaction pinning: #1599 #1632

Draft
wants to merge 31 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0b8a6bd
Counted transaction model for selective permanode storage capabilitie…
ovanwijk Aug 7, 2019
27fa821
- Removed counted transaction model
ovanwijk Aug 20, 2019
d690463
- Added a separate permanent storage provider for permanent storage
ovanwijk Aug 21, 2019
18d6ced
Merge branch 'dev' into SPstorage
ovanwijk Aug 21, 2019
c28bbaa
Removed the countered transaction model, just pinning, unpinning and …
ovanwijk Sep 4, 2019
e27f1e7
Renaming and comments
ovanwijk Sep 9, 2019
30d827b
Merge branch 'dev' into SPstorage
ovanwijk Sep 30, 2019
c989470
Fix for RocksDBPPPImpl to handle integer indexes.
ovanwijk Sep 30, 2019
be9fd59
Name changes and comments
ovanwijk Sep 30, 2019
5d5d463
Added boolean return values for transactionPinning
ovanwijk Sep 30, 2019
fe988f7
Revert test code to original code
ovanwijk Sep 30, 2019
4b21d42
Space removal
ovanwijk Sep 30, 2019
322764a
Braces fix
ovanwijk Sep 30, 2019
300ec78
Style updates and comments
ovanwijk Oct 1, 2019
1416ada
Style updates
ovanwijk Oct 1, 2019
68680f8
Import hell, why is this better then .* ?
ovanwijk Oct 1, 2019
74f86e7
Constructor comment and boolean response comment
ovanwijk Oct 1, 2019
2a8330d
Merge branch 'dev' into SPstorage
ovanwijk Nov 5, 2019
0c96323
Update src/main/java/com/iota/iri/storage/rocksDB/RocksDBPPPImpl.java
ovanwijk Nov 10, 2019
734fa04
Update src/main/java/com/iota/iri/storage/rocksDB/RocksDBPPPImpl.java
ovanwijk Nov 10, 2019
5d467d9
Update src/main/java/com/iota/iri/service/API.java
ovanwijk Nov 10, 2019
9dee4cd
Update src/main/java/com/iota/iri/service/API.java
ovanwijk Nov 10, 2019
e6288e9
Update src/main/java/com/iota/iri/service/API.java
ovanwijk Nov 10, 2019
06d35b8
Update src/main/java/com/iota/iri/storage/rocksDB/RocksDBPPPImpl.java
ovanwijk Nov 10, 2019
bf0fb20
Update src/main/java/com/iota/iri/storage/rocksDB/RocksDBPPPImpl.java
ovanwijk Nov 10, 2019
7faad38
Update src/main/java/com/iota/iri/service/API.java
ovanwijk Nov 10, 2019
3363209
Merge branch 'dev' into SPstorage
ovanwijk Nov 18, 2019
5abc785
Commit and merge
ovanwijk Nov 19, 2019
e5a8f16
Null fix and mayExist fix
ovanwijk Nov 19, 2019
97d5ec0
Fix API check
ovanwijk Jan 20, 2020
920e60b
Merge branch 'dev' into SPstorage
ovanwijk Jan 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/main/java/com/iota/iri/Iota.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.iota.iri;

import java.util.List;
import java.util.Map;

import com.iota.iri.storage.rocksDB.RocksDBPPPImpl;
import org.apache.commons.lang3.NotImplementedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.iota.iri.conf.IotaConfig;
import com.iota.iri.controllers.TipsViewModel;
import com.iota.iri.controllers.TransactionViewModel;
Expand Down Expand Up @@ -272,6 +280,24 @@ private void initializeTangle() {
if (configuration.isZmqEnabled()) {
tangle.addMessageQueueProvider(new ZmqMessageQueueProvider(configuration));
}

if(configuration.isSelectivePermaEnabled()){
switch (configuration.getPermaMainDb()) {
case "rocksdb": {
RocksDBPPPImpl ppp = new RocksDBPPPImpl(
configuration.getPermaDbPath(),
configuration.getPermaDbLogPath(),
configuration.getPermaDbCacheSize());

tangle.addPersistenceProvider(ppp);
tangle.addPermanentPersistenceProvider(ppp);
break;
}
default: {
throw new NotImplementedException("No such database type.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to use UnsupportedOperationException, just because it doesn't have a dependency on a 3rd party library

}
}
}
}

/**
Expand Down
95 changes: 95 additions & 0 deletions src/main/java/com/iota/iri/conf/BaseIotaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public abstract class BaseIotaConfig implements IotaConfig {
protected boolean revalidate = Defaults.REVALIDATE;
protected boolean rescanDb = Defaults.RESCAN_DB;

//PERMADB
protected boolean permaDbEnabled = Defaults.PERMADB_ENABLED;
protected String permaDbPath = Defaults.PERMADB_PATH;
protected String permaDbLogPath = Defaults.PERMADB_LOG_PATH;
protected int permaDbCacheSize = Defaults.PERMADB_CACHE_SIZE; //KB
protected String permaMainDb = Defaults.PERMAMAIN_DB;
protected boolean permaRevalidate = Defaults.PERMAREVALIDATE;
protected boolean permaRescanDb = Defaults.PERMARESCAN_DB;

//Protocol
protected double pSendMilestone = Defaults.P_SEND_MILESTONE;

Expand Down Expand Up @@ -384,6 +393,83 @@ protected void setIxiDir(String ixiDir) {
this.ixiDir = ixiDir;
}

//------- PERMADB -------------
@Override
public boolean isSelectivePermaEnabled() { return this.permaDbEnabled;}

@JsonProperty
@Parameter(names = {"--permadb-enabled"}, description = PermaDBConfig.Descriptions.PERMADB_ENABLED)
protected void setPermaDbEnabled(boolean enabled) {
this.permaDbEnabled = enabled;
}

@Override
public String getPermaDbPath() {
return permaDbPath;
}

@JsonProperty
@Parameter(names = {"--perma-db-path"}, description = PermaDBConfig.Descriptions.PERMADB_PATH)
protected void setPermaDbPath(String permaDbPath) {
this.permaDbPath = permaDbPath;
}

@Override
public String getPermaDbLogPath() {
return dbLogPath;
}

@JsonProperty
@Parameter(names = {"--perma-db-log-path"}, description = PermaDBConfig.Descriptions.PERMADB_LOG_PATH)
protected void setPermaDbLogPath(String permaDbLogPath) {
this.permaDbLogPath = permaDbLogPath;
}

@Override
public int getPermaDbCacheSize() {
return permaDbCacheSize;
}

@JsonProperty
@Parameter(names = {"--perma-db-cache-size"}, description = PermaDBConfig.Descriptions.PERMADB_CACHE_SIZE)
protected void setPermaDbCacheSize(int permaDbCacheSize) {
this.permaDbCacheSize = permaDbCacheSize;
}

@Override
public String getPermaMainDb() {
return permaMainDb;
}

@JsonProperty
@Parameter(names = {"--perma-db"}, description = PermaDBConfig.Descriptions.PERMAMAIN_DB)
protected void setPermaMainDb(String permaMainDb) {
this.permaMainDb = permaMainDb;
}

@Override
public boolean permaIsRevalidate() {
return permaRevalidate;
}

@JsonProperty
@Parameter(names = {"--perma-revalidate"}, description = PermaDBConfig.Descriptions.PERMAREVALIDATE)
protected void setPermaRevalidate(boolean permaRevalidate) {
this.permaRevalidate = permaRevalidate;
}

@Override
public boolean permaIsRescanDb() {
return this.permaRescanDb;
}

@JsonProperty
@Parameter(names = {"--perma-rescan"}, description = PermaDBConfig.Descriptions.PERMARESCAN_DB)
protected void setPermaRescanDb(boolean permaRescanDb) {
this.permaRescanDb = permaRescanDb;
}
//-----------------------------

@Override
public String getDbPath() {
return dbPath;
Expand Down Expand Up @@ -869,6 +955,15 @@ public interface Defaults {
boolean REVALIDATE = false;
boolean RESCAN_DB = false;

//PERMADB
boolean PERMADB_ENABLED = true;
String PERMADB_PATH = "mainnetpermadb";
String PERMADB_LOG_PATH = "mainnetpermadb.log";
int PERMADB_CACHE_SIZE = 100_000;
String PERMAMAIN_DB = "rocksdb";
boolean PERMAREVALIDATE = false;
boolean PERMARESCAN_DB = false;

//Protocol
double P_SEND_MILESTONE = 0.02d;
int MWM = 14;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/iota/iri/conf/IotaConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
* In charge of how we parse the configuration from given inputs.
*/
public interface IotaConfig extends APIConfig, NodeConfig,
IXIConfig, DbConfig, ConsensusConfig, ZMQConfig, TipSelConfig, PearlDiverConfig, SolidificationConfig {
IXIConfig, DbConfig, PermaDBConfig,
ConsensusConfig, ZMQConfig, TipSelConfig, PearlDiverConfig, SolidificationConfig {
File CONFIG_FILE = new File("iota.ini");

/**
Expand Down
72 changes: 72 additions & 0 deletions src/main/java/com/iota/iri/conf/PermaDBConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.iota.iri.conf;

/**
* Configurations for tangle database.
*/
public interface PermaDBConfig extends Config {


/**
* Default Value: {@value BaseIotaConfig.Defaults#PERMADB_ENABLED}
*
* @return {@value PermaDBConfig.Descriptions#PERMADB_ENABLED}
*/
boolean isSelectivePermaEnabled();

/**
* Default Value: {@value BaseIotaConfig.Defaults#PERMADB_PATH}
*
* @return {@value PermaDBConfig.Descriptions#PERMADB_PATH}
*/
String getPermaDbPath();

/**
* Default Value: {@value BaseIotaConfig.Defaults#PERMADB_LOG_PATH}
*
* @return {@value PermaDBConfig.Descriptions#PERMADB_LOG_PATH}
*/
String getPermaDbLogPath();

/**
* Default Value: {@value BaseIotaConfig.Defaults#PERMADB_CACHE_SIZE}
*
* @return {@value PermaDBConfig.Descriptions#PERMADB_CACHE_SIZE}
*/
int getPermaDbCacheSize();

/**
* Default Value: {@value BaseIotaConfig.Defaults#PERMAMAIN_DB}
*
* @return {@value PermaDBConfig.Descriptions#PERMAMAIN_DB}
*/
String getPermaMainDb();

/**
* Default Value: {@value BaseIotaConfig.Defaults#PERMAREVALIDATE}
*
* @return {@value PermaDBConfig.Descriptions#PERMAREVALIDATE}
*/
boolean permaIsRevalidate();

/**
* Default Value: {@value BaseIotaConfig.Defaults#PERMARESCAN_DB}
*
* @return {@value PermaDBConfig.Descriptions#PERMARESCAN_DB}
*/
boolean permaIsRescanDb();

/**
* Field descriptions
*/
interface Descriptions {

String PERMADB_PATH = "The folder where the DB saves its data.";
String PERMADB_LOG_PATH = "The folder where the DB logs info";
String PERMADB_CACHE_SIZE = "The size of the DB cache in KB";
String PERMAMAIN_DB = "The DB engine used to store the transactions. Currently only RocksDB is supported.";
String PERMAREVALIDATE = "Reload from the db data about confirmed transaction (milestones), state of the ledger, " +
"and transaction metadata.";
String PERMARESCAN_DB = "Rescan all transaction metadata (Approvees, Bundles, and Tags)";
String PERMADB_ENABLED = "Enables secondary permanent storage";
}
}
1 change: 0 additions & 1 deletion src/main/java/com/iota/iri/model/persistables/Hashes.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public void readMetadata(byte[] bytes) {

}


@Override
public boolean canMerge() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public void readMetadata(byte[] bytes) {

}


@Override
public boolean canMerge() {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ public boolean canMerge() {
return false;
}


@Override
public Persistable mergeInto(Persistable source) throws OperationNotSupportedException {
throw new OperationNotSupportedException("This object is not mergeable");
}


@Override
public boolean exists() {
return exists;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,6 @@ public void readMetadata(byte[] bytes) {
parsed = true;
}



@Override
public boolean canMerge() {
return false;
Expand Down
Loading