Skip to content

Commit

Permalink
Add ability to add new developers.
Browse files Browse the repository at this point in the history
  • Loading branch information
retsamknaps committed Aug 12, 2017
1 parent 6cb643f commit 803735d
Show file tree
Hide file tree
Showing 30 changed files with 615 additions and 113 deletions.
Binary file modified lib/i2p.jar
Binary file not shown.
Binary file modified lib/mstreaming.jar
Binary file not shown.
Binary file modified lib/router.jar
Binary file not shown.
Binary file modified lib/streaming.jar
Binary file not shown.
27 changes: 3 additions & 24 deletions src/aktie/DumpIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import java.io.File;
import java.io.IOException;

import org.json.JSONObject;

import aktie.data.CObj;
import aktie.index.CObjList;
import aktie.index.DumpIndexUtil;
import aktie.index.Index;

public class DumpIndex
Expand Down Expand Up @@ -36,27 +33,9 @@ public static void main ( String args[] )
System.exit ( 1 );
}

CObjList lst = index.getAllCObj();

for ( int c = 0; c < lst.size(); c++ )
{
try
{
CObj co = lst.get ( c );
JSONObject jo = co.GETPRIVATEJSON();
System.out.println ( jo.toString ( 4 ) );
System.out.println ( "NAME: " + co.getString ( CObj.NAME ) + " payment: " +
co.checkPayment ( Wrapper.NEWPAYMENT ) );
}

catch ( IOException e )
{
e.printStackTrace();
}

}
DumpIndexUtil.dumpIndex ( index );
index.close();

lst.close();
}

}
16 changes: 14 additions & 2 deletions src/aktie/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

import aktie.crypto.Utils;
import aktie.data.CObj;
import aktie.data.DeveloperIdentity;
import aktie.data.HH2Session;
import aktie.index.CObjList;
import aktie.index.Index;
import aktie.index.IndexInterface;
import aktie.net.ConnectionListener;
import aktie.net.ConnectionManager2;
import aktie.net.DownloadFileProcessor;
import aktie.net.GetSendData2;
import aktie.net.InSpamExProcessor;
import aktie.net.Net;
Expand All @@ -21,6 +23,7 @@
import aktie.upgrade.UpgradeControllerCallback;
import aktie.user.IdentityManager;
import aktie.user.NewCommunityProcessor;
import aktie.user.NewDeveloperProcessor;
import aktie.user.NewFileProcessor;
import aktie.user.NewForceSearcher;
import aktie.user.NewIdentityProcessor;
Expand Down Expand Up @@ -103,12 +106,15 @@ public Node ( String nodedir, Net net, UpdateCallback uc,
shareManager = new ShareManager ( session, requestHandler, index,
hasFileCreator, nfp, userQueue );

ProcessQueue dlQueue = new ProcessQueue ( "downloadQueue" );
dlQueue.addProcessor ( new DownloadFileProcessor ( hasFileCreator ) );

NewPushProcessor pusher = new NewPushProcessor ( index, conMan );
userQueue.addProcessor ( new NewQueryProcessor ( index ) );
userQueue.addProcessor ( new NewCommunityProcessor ( session, conMan, index, spamtool, usrCallback ) );
userQueue.addProcessor ( nfp );
NewIdentityProcessor nip = new NewIdentityProcessor ( network, conMan, session,
index, usrCallback, netCallback, conCallback, conMan, requestHandler, spamtool );
index, usrCallback, netCallback, conCallback, conMan, requestHandler, spamtool, dlQueue );
nip.setTmpDir ( tmpDir );
userQueue.addProcessor ( nip );
userQueue.addProcessor ( new NewMembershipProcessor ( session, conMan, index, spamtool, usrCallback ) );
Expand All @@ -117,11 +123,12 @@ public Node ( String nodedir, Net net, UpdateCallback uc,
userQueue.addProcessor ( new NewPrivateMessageProcessor ( session, index, pusher, spamtool, usrCallback ) );
userQueue.addProcessor ( new NewSubscriptionProcessor ( session, conMan, index, spamtool, usrCallback ) );
userQueue.addProcessor ( new NewSpamExProcessor ( session, index, identManager, usrCallback ) ) ;
userQueue.addProcessor(new NewDeveloperProcessor(index, identManager, usrCallback));
userQueue.addProcessor ( new InSpamExProcessor ( session, index, spamtool, null, null ) );
userQueue.addProcessor ( new NewForceSearcher ( index ) );

UsrStartDestinationProcessor usdp = new UsrStartDestinationProcessor ( network, conMan, session,
index, usrCallback, netCallback, conCallback, conMan, requestHandler, spamtool );
index, usrCallback, netCallback, conCallback, conMan, requestHandler, spamtool, dlQueue );
usdp.setTmpDir ( tmpDir );
userQueue.addProcessor ( usdp );
userQueue.addProcessor ( new UsrReqComProcessor ( identManager, index ) );
Expand Down Expand Up @@ -216,6 +223,11 @@ public void newDeveloperIdentity ( String id )
{
identManager.newDeveloperIdentity ( id );
}

public DeveloperIdentity getDeveloper(String id)
{
return identManager.getDeveloperIdentity(id);
}

public void priorityEnqueue ( CObj o )
{
Expand Down
3 changes: 3 additions & 0 deletions src/aktie/NodeInterface.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aktie;

import aktie.data.CObj;
import aktie.data.DeveloperIdentity;
import aktie.index.CObjList;
import aktie.index.IndexInterface;
import aktie.net.GetSendData2;
Expand Down Expand Up @@ -35,5 +36,7 @@ public interface NodeInterface
public NodeUpgrader getUpgrader();

public void close();

public DeveloperIdentity getDeveloper(String id);

}
2 changes: 1 addition & 1 deletion src/aktie/ProcessQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ProcessQueue ( String n )
queue = new ConcurrentLinkedDeque<Object>();
processor = new BatchProcessor();
name = n;
Thread t = new Thread ( this, "Process Queue Thread" );
Thread t = new Thread ( this, name );
t.start();
}

Expand Down
17 changes: 11 additions & 6 deletions src/aktie/StandardI2PNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.json.JSONTokener;

import aktie.data.CObj;
import aktie.data.DeveloperIdentity;
import aktie.i2p.I2PNet;
import aktie.index.CObjList;
import aktie.index.Upgrade0301;
Expand Down Expand Up @@ -129,9 +130,10 @@ public void nodeStarted()

mlst.close();

if ( !Wrapper.TESTNODE )
File devid = new File ( nodeDir + File.separator + "developerid.dat" );

if ( !Wrapper.TESTNODE || StandardI2PNode.TESTLOADDEFAULTS )
{
File devid = new File ( nodeDir + File.separator + "developerid.dat" );

if ( devid.exists() )
{
Expand Down Expand Up @@ -368,6 +370,10 @@ public void closeNode()
}

}

public DeveloperIdentity getDeveloper(String id) {
return node.getDeveloper(id);
}

private void preStartUpdate()
{
Expand Down Expand Up @@ -479,22 +485,22 @@ private void loadDefaults()
//Load default seed file.
File defseedfile = new File ( nodeDir + File.separator + "defseed.dat" );

if ( defseedfile.exists() )
if ( defseedfile.exists() && defseedfile.length() > 0 )
{
loadSeed ( defseedfile );
}

File spamex = new File ( nodeDir + File.separator + "spamex.dat" );

if ( spamex.exists() )
if ( spamex.exists() && spamex.length() > 0 )
{
loadSpamEx ( spamex );
}

//Load default communities and subscribe.
File defcomfile = new File ( nodeDir + File.separator + "defcom.dat" );

if ( defcomfile.exists() )
if ( defcomfile.exists() && defcomfile.length() > 0 )
{
loadDefCommunitySubs ( defcomfile );
}
Expand Down Expand Up @@ -579,7 +585,6 @@ public void loadDeveloperIdentity ( File f )
{
CObj co = new CObj();
co.loadJSON ( o );
node.getUpgrader().addDeveloperId ( co.getId() );
node.newDeveloperIdentity ( co.getId() );

try
Expand Down
16 changes: 13 additions & 3 deletions src/aktie/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Wrapper
//the upgrade file added to the network by the developer account.
//This keeps new installs from downloading the same version as
//an upgrade
public static long RELEASETIME = ( 1497499414L * 1000L ) + 3600000L;
public static long RELEASETIME = ( 1502555389L * 1000L ) + 3600000L;

//Hash cash payment values
//Process for updating payment: Only increase payment value.
Expand Down Expand Up @@ -265,6 +265,7 @@ public static int Main ( String args[] )
File uplst[] = updir.listFiles();
System.out.println ( "Upgrade list: " + uplst.length );

File upgradefile = null;
for ( int c = 0; c < uplst.length; c++ )
{
File uf = uplst[c];
Expand All @@ -278,11 +279,20 @@ public static int Main ( String args[] )

if ( len != null && len.equals ( rlen ) )
{
unZipUpgrade ( uf );
if (upgradefile == null || upgradefile.lastModified() > uf.lastModified() ) {
upgradefile = uf;
}

}

saveUpdateLength ( ufn, "-1" );
}

if (upgradefile != null)
{
System.out.println("Upgrading from file: " + upgradefile);
unZipUpgrade ( upgradefile );
saveUpdateLength ( upgradefile.getName(), "-1" );

}

//Just run it!
Expand Down
1 change: 1 addition & 0 deletions src/aktie/data/CObj.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class CObj
public static String CHECKMEM = "chkmem";
public static String CHECKSUB = "chksub";
public static String CHECKCOMP = "chkcomp";
public static String DEVELOPER = "dev";

//Types - no indexed.
public static String INDEX_QUERY = "index_query";
Expand Down
5 changes: 5 additions & 0 deletions src/aktie/gui/NewPostDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,11 @@ public void widgetSelected ( SelectionEvent e )
newStringDialog.open();
}

if ( "Boolean".equals ( s ) )
{
newBooleanDialog.open();
}

}

@Override
Expand Down
119 changes: 119 additions & 0 deletions src/aktie/gui/PaymentThreadsDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package aktie.gui;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import aktie.Wrapper;

public class PaymentThreadsDialog extends Dialog
{
private Text newRank;
private Text text_1;

/**
Create the dialog.
@param parentShell
*/
public PaymentThreadsDialog ( Shell parentShell )
{
super ( parentShell );
setShellStyle ( getShellStyle() | SWT.RESIZE );
}

private void setTextRank()
{
if ( newRank != null && ( !newRank.isDisposed() ) )
{
newRank.setText ( Integer.toString ( Wrapper.getPaymentThreads() ) );
}

}

@Override
public int open()
{
setTextRank();
return super.open();
}

/**
Create contents of the dialog.
@param parent
*/
@Override
protected Control createDialogArea ( Composite parent )
{
Composite container = ( Composite ) super.createDialogArea ( parent );
container.setLayout ( new GridLayout ( 2, false ) );
new Label ( container, SWT.NONE );

text_1 = new Text ( container, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL );
text_1.setLayoutData ( new GridData ( SWT.FILL, SWT.CENTER, true, true, 1, 1 ) );
text_1.setEditable ( false );
text_1.setText ( "Here you set the number of threads to use for generating "
+ "spam payments. The more threads the faster it will be generated, "
+ "but more CPU resources will be used." );

Label lblNewRank = new Label ( container, SWT.NONE );
lblNewRank.setLayoutData ( new GridData ( SWT.RIGHT, SWT.CENTER, false, false, 1, 1 ) );
lblNewRank.setText ( "Threads for Spam Payment" );

newRank = new Text ( container, SWT.BORDER );
newRank.setLayoutData ( new GridData ( SWT.FILL, SWT.CENTER, true, false, 1, 1 ) );

setTextRank();

return container;
}

/**
Create contents of the button bar.
@param parent
*/
@Override
protected void createButtonsForButtonBar ( Composite parent )
{
createButton ( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
createButton ( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
}

@Override
protected void okPressed()
{
try
{
int nv = Integer.valueOf ( newRank.getText() );
Wrapper.setPaymentThreads ( nv );
}

catch ( Exception e )
{
e.printStackTrace();
}

}

/**
Return the initial size of the dialog.
*/
@Override
protected Point getInitialSize()
{
return new Point ( 450, 192 );
}

public Text getNewRank()
{
return newRank;
}

}
Loading

0 comments on commit 803735d

Please sign in to comment.