Skip to content

Commit

Permalink
Version including runtime parameters to use two nodes on a single
Browse files Browse the repository at this point in the history
machine as described in :
https://www.multichain.com/qa/2817/how-to-run-datadir-in-multichain?show=2822#a2822
Now, when you create Command object you can specify these parameters.
More documentation has to come.
  • Loading branch information
[a561842] hubert marteau committed Sep 7, 2018
1 parent 5ba6326 commit e7b6561
Show file tree
Hide file tree
Showing 22 changed files with 284 additions and 76 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.multichainjavaapi</groupId>
<artifactId>MultiChainJavaAPI</artifactId>
<version>0.4.14-SNAPSHOT</version>
<version>0.4.15-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
62 changes: 54 additions & 8 deletions src/main/java/multichain/command/AddressCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

/**
* @author Ub - H. MARTEAU
* @version 4.13
* @version 4.15
*/
public class AddressCommand extends QueryBuilderAddress {

public AddressCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public AddressCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down Expand Up @@ -204,6 +204,16 @@ public final List<Address> getAddressesList() throws MultichainException {

return addresses;
}
public final List<Address> getAddressesList(boolean verbose) throws MultichainException {
List<Address> addresses = new ArrayList<Address>();

Object objectAddresses = executeGetAddresses(verbose);
if (verifyInstance(objectAddresses, ArrayList.class) && verifyInstanceofList((ArrayList<Object>) objectAddresses, Address.class)) {
addresses = AddressFormatter.formatAddressesList((ArrayList<Object>) objectAddresses);
}

return addresses;
}

/**
* Returns a list of balances of all addresses in this node’s wallet
Expand Down Expand Up @@ -360,15 +370,23 @@ public List<BalanceAssetGeneral> getAddressBalances(String address) throws Multi
* @throws MultichainException
*/
public final String getNewAddress() throws MultichainException {
return getNewAddress(null);
}
public final String getNewAddress(String label) throws MultichainException {
String stringAddress = "";

Object objectAddress = executeGetNewAddress();

Object objectAddress = null;
if (label == null || label.isEmpty()) {
objectAddress = executeGetNewAddress();
} else {
objectAddress = executeGetNewAddress(label);
}
if (verifyInstance(objectAddress, String.class)) {
stringAddress = (String) objectAddress;
}

return stringAddress;
}
}

/**
*
Expand All @@ -390,17 +408,25 @@ public final String getNewAddress() throws MultichainException {
* @throws MultichainException
*/
public final Address getNewAddressFilled() throws MultichainException {
return getNewAddressFilled(null);
}
public final Address getNewAddressFilled(String label) throws MultichainException {
Address address = new Address();

Object objectAddress = executeGetNewAddress();
Object objectAddress = null;
if (label == null || label.isEmpty()) {
objectAddress = executeGetNewAddress();
} else {
objectAddress = executeGetNewAddress(label);
}
if (verifyInstance(objectAddress, String.class)) {
String stringAddress = (String) objectAddress;

address = validateAddress(stringAddress);
}

return address;
}
}

/**
* Adds address to the wallet, without an associated private key, to create
Expand Down Expand Up @@ -429,6 +455,26 @@ public final Address getNewAddressFilled() throws MultichainException {
public void importAddress(String address, String label, boolean rescan) throws MultichainException {
/* String systemMessage = */executeImportAddress(address, label, rescan);
}

/**
* setaccount "address" "account"
*
* Sets the account associated with the given address.
*
* Arguments:
* 1. "address" (string, required) The address to be associated with an account.
* 2. "account" (string, required) The account to assign the address to.
*
* @param address
* @param label
* @return
* @throws MultichainException
*
* !!!!! Accounts are not supported with scalable wallet - if you need accounts, run multichaind -walletdbversion=1 -rescan, but the wallet will perform worse
*/
public void setAccount(String address, String label) throws MultichainException {
executeSetAccount(address, label);
}

/**
* Get information about an address
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/multichain/command/BalanceCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

/**
* @author Ub - H. MARTEAU
* @version 4.13
* @version 4.15
*/
public class BalanceCommand extends QueryBuilderBalance {
public BalanceCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public BalanceCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/multichain/command/BlockCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

/**
* @author Ub - H. MARTEAU
* @version 4.8
* @version 4.15
*/
public class BlockCommand extends QueryBuilderBlock {

public BlockCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public BlockCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/multichain/command/ChainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

/**
* @author Ub - H. MARTEAU
* @version 4.13
* @version 4.15
*/
public class ChainCommand extends QueryBuilderChain {

public ChainCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public ChainCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down Expand Up @@ -58,6 +58,9 @@ public ChainCommand(String ip, String port, String login, String password) {
public String getInfo() throws MultichainException {
return executeGetInfo();
}
public String getInfo(String arg) throws MultichainException {
return executeGetInfo(arg);
}

/**
* help ( command )
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/multichain/command/GrantCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* @author Ub - H. MARTEAU & Jagrut KOSTI
* @version 3.1
* @version 4.15
*/
public class GrantCommand extends QueryBuilderGrant {

Expand All @@ -33,8 +33,8 @@ public class GrantCommand extends QueryBuilderGrant {
public static int WALLET = QueryBuilderGrant.WALLET;
public static int WALLET_ISSUE = QueryBuilderGrant.WALLET_ISSUE;

public GrantCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public GrantCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/multichain/command/IssueCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

/**
* @author Ub - H. MARTEAU
* @version 4.4
* @version 4.15
*/
public class IssueCommand extends QueryBuilderIssue {

public IssueCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public IssueCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/multichain/command/KeyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@
*/
package multichain.command;

import java.util.ArrayList;
import java.util.List;

import multichain.command.builders.QueryBuilderBalance;
import multichain.command.builders.QueryBuilderKey;
import multichain.object.BalanceAsset;
import multichain.object.formatters.BalanceFormatter;

/**
* @author Ub - H. MARTEAU
* @version 3.0
* @version 4.15
*/
public class KeyCommand extends QueryBuilderKey {
public KeyCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public KeyCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

public Object getPrivkey(String privkey) throws MultichainException {
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/multichain/command/MessagingCommand.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
/*
* Copyright (C) 2017 Worldline, Inc.
*
* MultiChainJavaAPI code distributed under the GPLv3 license, see COPYING file.
* https://github.com/SimplyUb/MultiChainJavaAPI/blob/master/LICENSE
*
*/
package multichain.command;

import multichain.command.MultichainException;
import multichain.command.builders.QueryBuilderMessaging;
import multichain.object.Address;

/**
* @author Ub - H. MARTEAU
* @version 4.15
*/
public class MessagingCommand extends QueryBuilderMessaging {

public MessagingCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public MessagingCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/multichain/command/MiningCommand.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
/*
* Copyright (C) 2017 Worldline, Inc.
*
* MultiChainJavaAPI code distributed under the GPLv3 license, see COPYING file.
* https://github.com/SimplyUb/MultiChainJavaAPI/blob/master/LICENSE
*
*/
package multichain.command;

import multichain.command.builders.QueryBuilderMining;

/**
* @author Ub - H. MARTEAU
* @version 4.15
*/
public class MiningCommand extends QueryBuilderMining {
public MiningCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public MiningCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

public Object pauseMining() throws MultichainException {
Expand Down
33 changes: 17 additions & 16 deletions src/main/java/multichain/command/MultiChainCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* @author Ub - H. MARTEAU
* @version 3.0
* @version 4.15
*/
public class MultiChainCommand {
private AddressCommand addressCommand;
Expand All @@ -24,22 +24,23 @@ public class MultiChainCommand {
private WalletTransactionCommand walletTransactionCommand;
private KeyCommand keyCommand;

/**
*
*/
public MultiChainCommand(String ip, String port, String login, String password) {
public MultiChainCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
super();
addressCommand = new AddressCommand(ip, port, login, password);
balanceCommand = new BalanceCommand(ip, port, login, password);
blockCommand = new BlockCommand(ip, port, login, password);
chainCommand = new ChainCommand(ip, port, login, password);
grantCommand = new GrantCommand(ip, port, login, password);
issueCommand = new IssueCommand(ip, port, login, password);
messagingCommand = new MessagingCommand(ip, port, login, password);
rawTransactionCommand = new RAWTransactionCommand(ip, port, login, password);
streamCommand = new StreamCommand(ip, port, login, password);
walletTransactionCommand = new WalletTransactionCommand(ip, port, login, password);
keyCommand = new KeyCommand(ip, port, login, password);
addressCommand = new AddressCommand(ip, port, login, password, runtimeparameters);
balanceCommand = new BalanceCommand(ip, port, login, password, runtimeparameters);
blockCommand = new BlockCommand(ip, port, login, password, runtimeparameters);
chainCommand = new ChainCommand(ip, port, login, password, runtimeparameters);
grantCommand = new GrantCommand(ip, port, login, password, runtimeparameters);
issueCommand = new IssueCommand(ip, port, login, password, runtimeparameters);
messagingCommand = new MessagingCommand(ip, port, login, password, runtimeparameters);
rawTransactionCommand = new RAWTransactionCommand(ip, port, login, password, runtimeparameters);
streamCommand = new StreamCommand(ip, port, login, password, runtimeparameters);
walletTransactionCommand = new WalletTransactionCommand(ip, port, login, password, runtimeparameters);
keyCommand = new KeyCommand(ip, port, login, password, runtimeparameters);
}

public MultiChainCommand(String ip, String port, String login, String password) {
this(ip, port, login, password, null);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/multichain/command/RAWTransactionCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

/**
* @author Ub - H. MARTEAU
* @version 4.13
* @version 4.15
*/
public class RAWTransactionCommand extends QueryBuilderRAWTransaction {

public RAWTransactionCommand(String ip, String port, String login, String password) {
initialize(ip, port, login, password);
public RAWTransactionCommand(String ip, String port, String login, String password, RuntimeParameters runtimeparameters) {
initialize(ip, port, login, password, runtimeparameters);
}

/**
Expand Down
Loading

0 comments on commit e7b6561

Please sign in to comment.