Skip to content

Commit

Permalink
Initial models
Browse files Browse the repository at this point in the history
  • Loading branch information
llorllale committed Jun 25, 2018
1 parent e3d422d commit f323e05
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 112 deletions.
38 changes: 0 additions & 38 deletions src/main/java/io/zold/api/Amount.java

This file was deleted.

9 changes: 4 additions & 5 deletions src/main/java/io/zold/api/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,14 @@ public interface Network extends Iterable<Remote> {
/**
* Push the wallet to the network. The network will select the
* remote node with the highest score (with a minimum of {@code 16}).
* @param wallet the wallet
* @return whether {@code wallet} was successfully pushed or not
* @param wallet The wallet
*/
boolean push(Wallet wallet);
void push(Wallet wallet);

/**
* Pull a wallet from the network.
* @param id the wallet's {@link Wallet#id() id}
* @return the wallet
* @param id The wallet's {@link Wallet#id() id}
* @return The wallet
*/
Wallet pull(Long id);
}
2 changes: 1 addition & 1 deletion src/main/java/io/zold/api/Remote.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
public interface Remote {
/**
* This remote node's score.
* @return the score
* @return The score
*/
Score score();
}
9 changes: 6 additions & 3 deletions src/main/java/io/zold/api/Score.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package io.zold.api;

import org.cactoos.Text;

/**
* A remote node's score, equal to its number of suffixes.
*
Expand All @@ -33,8 +35,9 @@
*/
public interface Score extends Comparable<Score> {
/**
* The suffixes associated with this score.
* @return suffixes for this score
* The suffixes associated with this score. Each suffix is a text of the
* form {@code /[a-zA-Z0-9]+/}.
* @return Suffixes for this score
*/
Iterable<Suffix> suffixes();
Iterable<Text> suffixes();
}
38 changes: 0 additions & 38 deletions src/main/java/io/zold/api/Suffix.java

This file was deleted.

11 changes: 3 additions & 8 deletions src/main/java/io/zold/api/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,16 @@
package io.zold.api;

/**
* A payment transaction.
*
* @author George Aristy ([email protected])
* @version $Id$
* @since 0.1
*/
public interface Transaction {
/**
* Its ID.
* @return id of this transaction
*/
char id();

/**
* Amount involved in this transaction.
* @return the amount
* @return The amount
*/
Amount amount();
long amount();
}
19 changes: 10 additions & 9 deletions src/main/java/io/zold/api/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,33 @@
* @version $Id$
* @since 0.1
*/
@SuppressWarnings("PMD.ShortMethodName")
public interface Wallet {
/**
* 64-bit unsigned integer.
* @return
* This wallet's ID: an unsigned 64-bit integer.
* @return This wallet's id
* @checkstyle MethodName (2 lines)
*/
long id();

/**
* Make a payment.
* @param amt amount to pay
* @param bnf wallet ID of beneficiary
* @return the transaction
* @param amt Amount to pay in zents
* @param bnf Wallet ID of beneficiary
*/
Transaction pay(Amount amt, char bnf);
void pay(long amt, char bnf);

/**
* Merge both {@code this} and {@code other}. Fails if they are not the
* same wallet, as identified by their {@link #id() id}.
* @param other other wallet
* @return the merged wallet
* @param other Other wallet
* @return The merged wallet
*/
Wallet merge(Wallet other);

/**
* This wallet's ledger.
* @return this wallet's ledger
* @return This wallet's ledger
*/
Iterable<Transaction> ledger();
}
11 changes: 1 addition & 10 deletions src/main/java/io/zold/api/Wallets.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,7 @@
public interface Wallets extends Iterable<Wallet> {
/**
* Create a wallet.
* @return the new wallet
* @return The new wallet
*/
Wallet create();

/**
* Add/merge the wallet with our wallets.
* @param walt the wallet
* @return {@code walt} if we did not have this wallet, or a new
* instance of the same wallet if {@code walt} was merged with
* one we already had
*/
Wallet merge(Wallet walt);
}

0 comments on commit f323e05

Please sign in to comment.