Skip to content
Snippets Groups Projects
Commit 36f1ef57 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Fix currency id/name in Dao

[enh] Add WotRemoteService.sendCertification() implementation
[enh] Add NetworkRemoveService.getDifficulties()
parent 3422479e
Branches
Tags
No related merge requests found
Pipeline #4508 passed
Showing
with 223 additions and 88 deletions
...@@ -100,7 +100,7 @@ public class TransactionAction extends AbstractAction { ...@@ -100,7 +100,7 @@ public class TransactionAction extends AbstractAction {
Currency currency = ServiceLocator.instance().getBlockchainRemoteService().getCurrencyFromPeer(peer); Currency currency = ServiceLocator.instance().getBlockchainRemoteService().getCurrencyFromPeer(peer);
ServiceLocator.instance().getCurrencyService().save(currency); ServiceLocator.instance().getCurrencyService().save(currency);
peer.setCurrency(currency.getCurrencyName()); peer.setCurrency(currency.getId());
ServiceLocator.instance().getPeerService().save(peer); ServiceLocator.instance().getPeerService().save(peer);
...@@ -123,7 +123,7 @@ public class TransactionAction extends AbstractAction { ...@@ -123,7 +123,7 @@ public class TransactionAction extends AbstractAction {
} }
Wallet wallet = new Wallet( Wallet wallet = new Wallet(
currency.getCurrencyName(), currency.getId(),
null, null,
keypair.getPubKey(), keypair.getPubKey(),
keypair.getSecKey()); keypair.getSecKey());
...@@ -219,7 +219,7 @@ public class TransactionAction extends AbstractAction { ...@@ -219,7 +219,7 @@ public class TransactionAction extends AbstractAction {
logTxSummary(wallet); logTxSummary(wallet);
peers.stream().forEach(peer -> { peers.stream().forEach(peer -> {
peer.setCurrency(currency.getCurrencyName()); peer.setCurrency(currency.getId());
peerService.save(peer); peerService.save(peer);
log.debug(String.format("Send TX to [%s]...", peer)); log.debug(String.format("Send TX to [%s]...", peer));
......
...@@ -251,6 +251,10 @@ public class Configuration { ...@@ -251,6 +251,10 @@ public class Configuration {
return applicationConfig.getOptionAsInt(ConfigurationOption.NETWORK_TIMEOUT.getKey()); return applicationConfig.getOptionAsInt(ConfigurationOption.NETWORK_TIMEOUT.getKey());
} }
public int getNetworkLargerTimeout() {
return Math.max(30000, getNetworkTimeout());
}
public int getNetworkMaxTotalConnections() { public int getNetworkMaxTotalConnections() {
return applicationConfig.getOptionAsInt(ConfigurationOption.NETWORK_MAX_CONNECTIONS.getKey()); return applicationConfig.getOptionAsInt(ConfigurationOption.NETWORK_MAX_CONNECTIONS.getKey());
} }
......
...@@ -40,9 +40,11 @@ public interface CurrencyDao extends Bean, EntityDao<String, Currency> { ...@@ -40,9 +40,11 @@ public interface CurrencyDao extends Bean, EntityDao<String, Currency> {
void remove(final Currency currency); void remove(final Currency currency);
List<String> getCurrencyIds(); Set<String> getAllIds();
List<Currency> getCurrencies(long accountId); List<Currency> getAll();
List<Currency> getAllByAccount(long accountId);
/** /**
* Return the value of the last universal dividend * Return the value of the last universal dividend
......
...@@ -24,6 +24,7 @@ package org.duniter.core.client.dao; ...@@ -24,6 +24,7 @@ package org.duniter.core.client.dao;
import org.duniter.core.client.model.bma.EndpointApi; import org.duniter.core.client.model.bma.EndpointApi;
import org.duniter.core.client.model.bma.NetworkPeers; import org.duniter.core.client.model.bma.NetworkPeers;
import org.duniter.core.client.model.bma.NetworkWs2pHeads;
import org.duniter.core.client.model.local.Peer; import org.duniter.core.client.model.local.Peer;
import java.util.Collection; import java.util.Collection;
...@@ -56,6 +57,14 @@ public interface PeerDao extends EntityDao<String, Peer> { ...@@ -56,6 +57,14 @@ public interface PeerDao extends EntityDao<String, Peer> {
*/ */
List<NetworkPeers.Peer> getBmaPeersByCurrencyId(String currencyId, String[] pubkeys); List<NetworkPeers.Peer> getBmaPeersByCurrencyId(String currencyId, String[] pubkeys);
/**
* Get WS2p heads as BMA /network/ws2p/head format
* @param currencyId
* @param pubkeys use to filter on specific pubkeys. If null, not filtering
* @return
*/
List<NetworkWs2pHeads.Head> getWs2pPeersByCurrencyId(String currencyId, String[] pubkeys);
boolean isExists(String currencyId, String peerId); boolean isExists(String currencyId, String peerId);
Long getMaxLastUpTime(String currencyId); Long getMaxLastUpTime(String currencyId);
......
...@@ -23,6 +23,7 @@ package org.duniter.core.client.dao.mem; ...@@ -23,6 +23,7 @@ package org.duniter.core.client.dao.mem;
*/ */
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.duniter.core.client.dao.CurrencyDao; import org.duniter.core.client.dao.CurrencyDao;
import java.util.*; import java.util.*;
...@@ -61,15 +62,18 @@ public class MemoryCurrencyDaoImpl implements CurrencyDao { ...@@ -61,15 +62,18 @@ public class MemoryCurrencyDaoImpl implements CurrencyDao {
} }
@Override @Override
public List<String> getCurrencyIds() { public Set<String> getAllIds() {
return ImmutableList.copyOf(currencies.keySet()); return ImmutableSet.copyOf(currencies.keySet());
} }
@Override @Override
public List<org.duniter.core.client.model.local.Currency> getCurrencies(long accountId) { public List<org.duniter.core.client.model.local.Currency> getAll() {
List<org.duniter.core.client.model.local.Currency> result = new ArrayList<>(); return ImmutableList.copyOf(currencies.values());
result.addAll(currencies.values()); }
return result;
@Override
public List<org.duniter.core.client.model.local.Currency> getAllByAccount(long accountId) {
return ImmutableList.copyOf(currencies.values());
} }
@Override @Override
......
...@@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList; ...@@ -26,6 +26,7 @@ import com.google.common.collect.ImmutableList;
import org.duniter.core.client.dao.PeerDao; import org.duniter.core.client.dao.PeerDao;
import org.duniter.core.client.model.bma.EndpointApi; import org.duniter.core.client.model.bma.EndpointApi;
import org.duniter.core.client.model.bma.NetworkPeers; import org.duniter.core.client.model.bma.NetworkPeers;
import org.duniter.core.client.model.bma.NetworkWs2pHeads;
import org.duniter.core.client.model.local.Peer; import org.duniter.core.client.model.local.Peer;
import org.duniter.core.client.model.local.Peers; import org.duniter.core.client.model.local.Peers;
import org.duniter.core.util.Preconditions; import org.duniter.core.util.Preconditions;
...@@ -121,6 +122,17 @@ public class MemoryPeerDaoImpl implements PeerDao { ...@@ -121,6 +122,17 @@ public class MemoryPeerDaoImpl implements PeerDao {
return Peers.toBmaPeers(getPeersByCurrencyIdAndApiAndPubkeys(currencyId, null, pubkeys)); return Peers.toBmaPeers(getPeersByCurrencyIdAndApiAndPubkeys(currencyId, null, pubkeys));
} }
@Override
public List<NetworkWs2pHeads.Head> getWs2pPeersByCurrencyId(String currencyId, String[] pubkeys) {
Preconditions.checkNotNull(currencyId);
return getPeersByCurrencyIdAndApiAndPubkeys(currencyId, null, pubkeys)
.stream()
.map(Peers::toWs2pHead)
// Skip if no message
.filter(head -> head.getMessage() != null)
.collect(Collectors.toList());
}
@Override @Override
public boolean isExists(final String currencyId, final String peerId) { public boolean isExists(final String currencyId, final String peerId) {
......
...@@ -23,6 +23,9 @@ package org.duniter.core.client.model; ...@@ -23,6 +23,9 @@ package org.duniter.core.client.model;
*/ */
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.duniter.core.client.model.local.LocalEntity;
import java.io.Serializable; import java.io.Serializable;
/** /**
...@@ -36,6 +39,10 @@ public class BasicIdentity implements Serializable { ...@@ -36,6 +39,10 @@ public class BasicIdentity implements Serializable {
private static final long serialVersionUID = 8080689271400316984L; private static final long serialVersionUID = 8080689271400316984L;
public static final String PROPERTY_UID = "uid";
public static final String PROPERTY_PUBKEY = "pubkey";
public static final String PROPERTY_SIGNATURE = "signature";
private String pubkey; private String pubkey;
private String signature; private String signature;
...@@ -58,10 +65,14 @@ public class BasicIdentity implements Serializable { ...@@ -58,10 +65,14 @@ public class BasicIdentity implements Serializable {
this.signature = signature; this.signature = signature;
} }
@JsonIgnore
@Deprecated
public String getSelf() { public String getSelf() {
return signature; return signature;
} }
@JsonIgnore
@Deprecated
public void setSelf(String signature) { public void setSelf(String signature) {
this.signature = signature; this.signature = signature;
} }
......
...@@ -51,6 +51,7 @@ public class BlockchainBlock implements Serializable { ...@@ -51,6 +51,7 @@ public class BlockchainBlock implements Serializable {
public static final String PROPERTY_REVOKED = "revoked"; public static final String PROPERTY_REVOKED = "revoked";
public static final String PROPERTY_EXCLUDED = "excluded"; public static final String PROPERTY_EXCLUDED = "excluded";
public static final String PROPERTY_MEDIAN_TIME = "medianTime"; public static final String PROPERTY_MEDIAN_TIME = "medianTime";
public static final String PROPERTY_ISSUER = "issuer";
private static final long serialVersionUID = -5598140972293452669L; private static final long serialVersionUID = -5598140972293452669L;
......
package org.duniter.core.client.model.bma;
/*
* #%L
* UCoin Java :: Core Client API
* %%
* Copyright (C) 2014 - 2016 EIS
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import java.io.Serializable;
public class BlockchainDifficulties implements Serializable {
private static final long serialVersionUID = -5631089862715942431L;
private Long block;
private DifficultyLevel[] levels;
public Long getBlock() {
return block;
}
public void setBlock(Long block) {
this.block = block;
}
public DifficultyLevel[] getLevels() {
return levels;
}
public void setLevels(DifficultyLevel[] levels) {
this.levels = levels;
}
public static class DifficultyLevel implements Serializable {
private static final long serialVersionUID = 1L;
private String uid;
private int level;
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
}
}
...@@ -45,7 +45,7 @@ public class BlockchainMemberships extends BasicIdentity { ...@@ -45,7 +45,7 @@ public class BlockchainMemberships extends BasicIdentity {
this.memberships = memberships; this.memberships = memberships;
} }
public class Membership implements Serializable { public static class Membership implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String version; private String version;
......
...@@ -35,6 +35,8 @@ public interface Protocol { ...@@ -35,6 +35,8 @@ public interface Protocol {
String TYPE_MEMBERSHIP = "Membership"; String TYPE_MEMBERSHIP = "Membership";
String TYPE_CERTIFICATION = "Certification";
String TYPE_TRANSACTION = "Transaction"; String TYPE_TRANSACTION = "Transaction";
String TYPE_PEER = "Peer"; String TYPE_PEER = "Peer";
......
...@@ -113,7 +113,7 @@ public class Contact implements LocalEntity<Long>, Serializable { ...@@ -113,7 +113,7 @@ public class Contact implements LocalEntity<Long>, Serializable {
public boolean hasIdentityForCurrency(String currencyId) { public boolean hasIdentityForCurrency(String currencyId) {
return identities.stream() return identities.stream()
.anyMatch(identity -> identity.getCurrencyId() != null .anyMatch(identity -> identity.getCurrency() != null
&& currencyId.equals(identity.getCurrencyId())); && currencyId.equals(identity.getCurrency()));
} }
} }
...@@ -25,7 +25,6 @@ package org.duniter.core.client.model.local; ...@@ -25,7 +25,6 @@ package org.duniter.core.client.model.local;
import java.io.Serializable; import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import org.duniter.core.client.model.Account;
import org.duniter.core.client.model.bma.BlockchainParameters; import org.duniter.core.client.model.bma.BlockchainParameters;
/** /**
...@@ -33,7 +32,7 @@ import org.duniter.core.client.model.bma.BlockchainParameters; ...@@ -33,7 +32,7 @@ import org.duniter.core.client.model.bma.BlockchainParameters;
*/ */
public class Currency implements LocalEntity<String>, Serializable { public class Currency implements LocalEntity<String>, Serializable {
private String currencyName; private String id;
private Integer membersCount; private Integer membersCount;
private String firstBlockSignature; private String firstBlockSignature;
private Long lastUD; private Long lastUD;
...@@ -42,11 +41,11 @@ public class Currency implements LocalEntity<String>, Serializable { ...@@ -42,11 +41,11 @@ public class Currency implements LocalEntity<String>, Serializable {
public Currency() { public Currency() {
} }
public Currency(String currencyName, public Currency(String id,
String firstBlockSignature, String firstBlockSignature,
int membersCount, int membersCount,
BlockchainParameters parameters) { BlockchainParameters parameters) {
this.currencyName = currencyName; this.id = id;
this.firstBlockSignature = firstBlockSignature; this.firstBlockSignature = firstBlockSignature;
this.membersCount = membersCount; this.membersCount = membersCount;
this.parameters = parameters; this.parameters = parameters;
...@@ -54,12 +53,11 @@ public class Currency implements LocalEntity<String>, Serializable { ...@@ -54,12 +53,11 @@ public class Currency implements LocalEntity<String>, Serializable {
@JsonIgnore @JsonIgnore
public String getId() { public String getId() {
return currencyName; return id;
} }
public String getCurrencyName() public void setId(String id) {
{ this.id = id;
return currencyName;
} }
public Integer getMembersCount() { public Integer getMembersCount() {
...@@ -70,13 +68,6 @@ public class Currency implements LocalEntity<String>, Serializable { ...@@ -70,13 +68,6 @@ public class Currency implements LocalEntity<String>, Serializable {
return firstBlockSignature; return firstBlockSignature;
} }
public void setId(String id) {
this.currencyName = id;
}
public void setCurrencyName(String currencyName) {
this.currencyName = currencyName;
}
public void setMembersCount(Integer membersCount) { public void setMembersCount(Integer membersCount) {
this.membersCount = membersCount; this.membersCount = membersCount;
...@@ -103,6 +94,6 @@ public class Currency implements LocalEntity<String>, Serializable { ...@@ -103,6 +94,6 @@ public class Currency implements LocalEntity<String>, Serializable {
} }
public String toString() { public String toString() {
return currencyName; return id;
} }
} }
\ No newline at end of file
...@@ -23,29 +23,23 @@ package org.duniter.core.client.model.local; ...@@ -23,29 +23,23 @@ package org.duniter.core.client.model.local;
*/ */
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.duniter.core.client.model.BasicIdentity; import org.duniter.core.client.model.BasicIdentity;
public class Identity extends BasicIdentity { public class Identity extends BasicIdentity {
private static final long serialVersionUID = -7451079677730158794L; private static final long serialVersionUID = -7451079677730158794L;
public static final String PROPERTY_IS_MEMBER = "isMember";
public static final String PROPERTY_WAS_MEMBER = "wasMember";
private String timestamp = null; private String timestamp = null;
private Boolean isMember = null; private Boolean isMember = null;
private String currencyId; private Boolean wasMember = null;
/**
* The timestamp value of the signature date (a BLOCK_UID)
* @return
*/
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) { private String currency;
this.timestamp = timestamp;
}
/** /**
* Indicate whether the certification is written in the blockchain or not. * Indicate whether the certification is written in the blockchain or not.
...@@ -58,11 +52,35 @@ public class Identity extends BasicIdentity { ...@@ -58,11 +52,35 @@ public class Identity extends BasicIdentity {
this.isMember = isMember; this.isMember = isMember;
} }
public String getCurrencyId() { public Boolean getWasMember() {
return currencyId; return wasMember;
}
public void setWasMember(Boolean wasMember) {
this.wasMember = wasMember;
}
/**
* The timestamp value of the signature date (a BLOCK_UID)
* @return
*/
@JsonIgnore
public String getTimestamp() {
return timestamp;
}
@JsonIgnore
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
@JsonIgnore
public String getCurrency() {
return currency;
} }
public void setCurrencyId(String currencyId) { @JsonIgnore
this.currencyId = currencyId; public void setCurrency(String currency) {
this.currency = currency;
} }
} }
package org.duniter.core.client.model; package org.duniter.core.client.model.local;
/* /*
* #%L * #%L
...@@ -23,29 +23,20 @@ package org.duniter.core.client.model; ...@@ -23,29 +23,20 @@ package org.duniter.core.client.model;
*/ */
import org.duniter.core.client.model.local.Identity; import com.fasterxml.jackson.annotation.JsonIgnore;
public class Member extends Identity { public class Member extends Identity implements LocalEntity<String> {
private static final long serialVersionUID = 8448049949323699700L; private static final long serialVersionUID = 8448049949323699700L;
private String number; @JsonIgnore
public String getId() {
private String hash; return getPubkey();
public String getNumber() {
return number;
} }
public void setNumber(String number) { @JsonIgnore
this.number = number; public void setId(String pubkey) {
setPubkey(pubkey);
} }
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
} }
...@@ -24,10 +24,7 @@ package org.duniter.core.client.model.local; ...@@ -24,10 +24,7 @@ package org.duniter.core.client.model.local;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import org.duniter.core.client.model.bma.EndpointApi; import org.duniter.core.client.model.bma.*;
import org.duniter.core.client.model.bma.NetworkPeering;
import org.duniter.core.client.model.bma.NetworkPeers;
import org.duniter.core.client.model.bma.Protocol;
import org.duniter.core.util.CollectionUtils; import org.duniter.core.util.CollectionUtils;
import org.duniter.core.util.StringUtils; import org.duniter.core.util.StringUtils;
...@@ -147,6 +144,13 @@ public final class Peers { ...@@ -147,6 +144,13 @@ public final class Peers {
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
public static NetworkWs2pHeads.Head toWs2pHead(Peer peer) {
NetworkWs2pHeads.Head result = new NetworkWs2pHeads.Head();
// TODO : add implementation
return result;
}
public static Peer.PeerStatus getStatus(final Peer peer) { public static Peer.PeerStatus getStatus(final Peer peer) {
return peer.getStats() != null && return peer.getStats() != null &&
......
...@@ -50,6 +50,8 @@ public interface HttpService extends Service { ...@@ -50,6 +50,8 @@ public interface HttpService extends Service {
<T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass); <T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass);
<T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass, int timeout) ;
String getPath(Peer peer, String... absolutePath); String getPath(Peer peer, String... absolutePath);
String getPath(String... absolutePath); String getPath(String... absolutePath);
......
...@@ -152,8 +152,12 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean ...@@ -152,8 +152,12 @@ public class HttpServiceImpl implements HttpService, Closeable, InitializingBean
} }
public <T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass) { public <T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass) {
return executeRequest(peer, absolutePath, resultClass, 0);
}
public <T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass, int timeout) {
HttpGet httpGet = new HttpGet(peer.getUrl() + absolutePath); HttpGet httpGet = new HttpGet(peer.getUrl() + absolutePath);
return executeRequest(HttpClients.getThreadHttpClient(0), httpGet, resultClass); return executeRequest(HttpClients.getThreadHttpClient(timeout), httpGet, resultClass);
} }
public String getPath(Peer peer, String... absolutePath) { public String getPath(Peer peer, String... absolutePath) {
......
...@@ -58,15 +58,29 @@ public abstract class BaseRemoteServiceImpl implements Service, InitializingBean ...@@ -58,15 +58,29 @@ public abstract class BaseRemoteServiceImpl implements Service, InitializingBean
peerService = null; peerService = null;
} }
@Deprecated
public <T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass) { public <T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass) {
return httpService.executeRequest(peer, absolutePath, resultClass); return httpService.executeRequest(peer, absolutePath, resultClass);
} }
@Deprecated
public <T> T executeRequest(Peer peer, String absolutePath, Class<? extends T> resultClass, int timeout) {
return httpService.executeRequest(peer, absolutePath, resultClass, timeout);
}
@Deprecated
public <T> T executeRequest(String currencyId, String absolutePath, Class<? extends T> resultClass) { public <T> T executeRequest(String currencyId, String absolutePath, Class<? extends T> resultClass) {
Peer peer = peerService.getActivePeerByCurrencyId(currencyId); Peer peer = peerService.getActivePeerByCurrencyId(currencyId);
return httpService.executeRequest(peer, absolutePath, resultClass); return httpService.executeRequest(peer, absolutePath, resultClass);
} }
@Deprecated
public <T> T executeRequest(String currencyId, String absolutePath, Class<? extends T> resultClass, int timeout) {
Peer peer = peerService.getActivePeerByCurrencyId(currencyId);
return httpService.executeRequest(peer, absolutePath, resultClass, timeout);
}
@Deprecated
public <T> T executeRequest(HttpUriRequest request, Class<? extends T> resultClass) { public <T> T executeRequest(HttpUriRequest request, Class<? extends T> resultClass) {
return httpService.executeRequest(request, resultClass); return httpService.executeRequest(request, resultClass);
} }
...@@ -76,14 +90,17 @@ public abstract class BaseRemoteServiceImpl implements Service, InitializingBean ...@@ -76,14 +90,17 @@ public abstract class BaseRemoteServiceImpl implements Service, InitializingBean
return httpService.getPath(peer, aPath); return httpService.getPath(peer, aPath);
} }
@Deprecated
public String getPath(Peer peer, String aPath) { public String getPath(Peer peer, String aPath) {
return httpService.getPath(peer, aPath); return httpService.getPath(peer, aPath);
} }
@Deprecated
public URIBuilder getURIBuilder(URI baseUri, String... path) { public URIBuilder getURIBuilder(URI baseUri, String... path) {
return httpService.getURIBuilder(baseUri, path); return httpService.getURIBuilder(baseUri, path);
} }
@Deprecated
public URIBuilder getURIBuilder(URL baseUrl, String... path) { public URIBuilder getURIBuilder(URL baseUrl, String... path) {
try { try {
return httpService.getURIBuilder(baseUrl.toURI(), path); return httpService.getURIBuilder(baseUrl.toURI(), path);
......
...@@ -23,6 +23,7 @@ package org.duniter.core.client.service.bma; ...@@ -23,6 +23,7 @@ package org.duniter.core.client.service.bma;
*/ */
import org.duniter.core.beans.Service; import org.duniter.core.beans.Service;
import org.duniter.core.client.model.bma.BlockchainDifficulties;
import org.duniter.core.client.model.local.Identity; import org.duniter.core.client.model.local.Identity;
import org.duniter.core.client.model.bma.BlockchainBlock; import org.duniter.core.client.model.bma.BlockchainBlock;
import org.duniter.core.client.model.bma.BlockchainMemberships; import org.duniter.core.client.model.bma.BlockchainMemberships;
...@@ -49,6 +50,8 @@ public interface BlockchainRemoteService extends Service { ...@@ -49,6 +50,8 @@ public interface BlockchainRemoteService extends Service {
*/ */
BlockchainParameters getParameters(String currencyId, boolean useCache); BlockchainParameters getParameters(String currencyId, boolean useCache);
BlockchainParameters getParameters(Peer peer, boolean useCache);
/** /**
* get the blockchain parameters (currency parameters) * get the blockchain parameters (currency parameters)
* *
...@@ -84,6 +87,8 @@ public interface BlockchainRemoteService extends Service { ...@@ -84,6 +87,8 @@ public interface BlockchainRemoteService extends Service {
*/ */
Long getBlockDividend(String currencyId, long number) throws BlockNotFoundException; Long getBlockDividend(String currencyId, long number) throws BlockNotFoundException;
Long getBlockDividend(Peer peer, long number) throws BlockNotFoundException;
/** /**
* Retrieve a block, by id (from 0 to current) * Retrieve a block, by id (from 0 to current)
* *
...@@ -124,6 +129,7 @@ public interface BlockchainRemoteService extends Service { ...@@ -124,6 +129,7 @@ public interface BlockchainRemoteService extends Service {
* *
* @return * @return
*/ */
BlockchainBlock getCurrentBlock(Peer peer, boolean useCache);
BlockchainBlock getCurrentBlock(String currencyId, boolean useCache); BlockchainBlock getCurrentBlock(String currencyId, boolean useCache);
/** /**
...@@ -131,15 +137,8 @@ public interface BlockchainRemoteService extends Service { ...@@ -131,15 +137,8 @@ public interface BlockchainRemoteService extends Service {
* *
* @return * @return
*/ */
BlockchainBlock getCurrentBlock(String currencyId);
/**
* Retrieve the current block
*
* @param peer the peer to use for request
* @return the last block
*/
BlockchainBlock getCurrentBlock(Peer peer); BlockchainBlock getCurrentBlock(Peer peer);
BlockchainBlock getCurrentBlock(String currencyId);
/** /**
* Retrieve the currency data, from peer * Retrieve the currency data, from peer
...@@ -149,23 +148,20 @@ public interface BlockchainRemoteService extends Service { ...@@ -149,23 +148,20 @@ public interface BlockchainRemoteService extends Service {
*/ */
Currency getCurrencyFromPeer(Peer peer); Currency getCurrencyFromPeer(Peer peer);
BlockchainParameters getBlockchainParametersFromPeer(Peer peer);
/** /**
* Retrieve the last emitted UD (or ud0 if not UD emitted yet) * Retrieve personal difficulties (level, uid)
*
* @param currencyId id of currency
* @return * @return
*/ */
long getLastUD(String currencyId); BlockchainDifficulties getDifficulties(Peer peer);
BlockchainDifficulties getDifficulties(String currencyId);
/** /**
* Retrieve the last emitted UD, from a peer (or ud0 if not UD emitted yet) * Retrieve the last emitted UD (or ud0 if not UD emitted yet)
* *
* @param currencyId id of currency
* @return * @return
*/ */
long getLastUD(Peer peer); long getLastUD(Peer peer);
long getLastUD(String currencyId);
/** /**
* Check is a identity is not already used by a existing member * Check is a identity is not already used by a existing member
...@@ -193,7 +189,6 @@ public interface BlockchainRemoteService extends Service { ...@@ -193,7 +189,6 @@ public interface BlockchainRemoteService extends Service {
*/ */
void loadMembership(String currencyId, Identity identity, boolean checkLookupForNonMember); void loadMembership(String currencyId, Identity identity, boolean checkLookupForNonMember);
BlockchainMemberships getMembershipByUid(String currencyId, String uid); BlockchainMemberships getMembershipByUid(String currencyId, String uid);
BlockchainMemberships getMembershipByPublicKey(String currencyId, String pubkey); BlockchainMemberships getMembershipByPublicKey(String currencyId, String pubkey);
...@@ -220,18 +215,18 @@ public interface BlockchainRemoteService extends Service { ...@@ -220,18 +215,18 @@ public interface BlockchainRemoteService extends Service {
* @param startOffset * @param startOffset
* @return * @return
*/ */
Map<Integer, Long> getUDs(Peer peer, long startOffset);
Map<Integer, Long> getUDs(String currencyId, long startOffset); Map<Integer, Long> getUDs(String currencyId, long startOffset);
/** /**
* Listening new block event * Listening new block event
* @param currencyId
* @param listener * @param listener
* @param autoReconnect * @param autoReconnect
* @return * @return
*/ */
WebsocketClientEndpoint addBlockListener(Peer peer, WebsocketClientEndpoint.MessageListener listener, boolean autoReconnect);
WebsocketClientEndpoint addBlockListener(String currencyId, WebsocketClientEndpoint.MessageListener listener, boolean autoReconnect); WebsocketClientEndpoint addBlockListener(String currencyId, WebsocketClientEndpoint.MessageListener listener, boolean autoReconnect);
WebsocketClientEndpoint addBlockListener(Peer peer, WebsocketClientEndpoint.MessageListener listener, boolean autoReconnect);
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment