Skip to content

Commit

Permalink
release 2.1.0 update (#372)
Browse files Browse the repository at this point in the history
* change abstract BlockNotifyCallBack class to interface

* place the underlying version definition in EnumNodeVersion class file.
  • Loading branch information
ywy2090 authored Aug 14, 2019
1 parent 8f2b6be commit 1150acc
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.math.BigInteger;

public abstract class BlockNotifyCallBack {
public interface BlockNotifyCallBack {

public abstract void onBlockNotify(int groupID, BigInteger blockNumber);
public void onBlockNotify(int groupID, BigInteger blockNumber);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DefaultBlockNotifyCallBack extends BlockNotifyCallBack {
public class DefaultBlockNotifyCallBack implements BlockNotifyCallBack {
private static Logger logger = LoggerFactory.getLogger(DefaultBlockNotifyCallBack.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.fisco.bcos.channel.protocol.ChannelPrococolExceiption;
import org.fisco.bcos.channel.protocol.ChannelProtocol;
import org.fisco.bcos.channel.protocol.EnumChannelProtocolVersion;
import org.fisco.bcos.channel.protocol.EnumNodeVersion;
import org.fisco.bcos.channel.protocol.EnumSocketChannelAttributeKey;
import org.fisco.bcos.fisco.EnumNodeVersion;
import org.fisco.bcos.web3j.protocol.ObjectMapperFactory;
import org.fisco.bcos.web3j.protocol.channel.ChannelEthereumService;
import org.fisco.bcos.web3j.protocol.core.Request;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.fisco.bcos.channel.protocol;
package org.fisco.bcos.fisco;

public enum EnumNodeVersion {
BCOS_2_0_0_RC1("2.0.0-rc1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.math.BigInteger;
import org.fisco.bcos.fisco.EnumNodeVersion;
import org.fisco.bcos.web3j.protocol.ObjectMapperFactory;
import org.fisco.bcos.web3j.protocol.Web3j;
import org.fisco.bcos.web3j.protocol.channel.StatusCode;
Expand Down Expand Up @@ -57,7 +58,8 @@ public class PrecompiledCommon {
public static String transferToJson(int code) throws IOException {
// adapt fisco-bcos rc1 || rc2 || rc3
String msg = "";
if (BCOS_VERSION == null || BCOS_RC1.equals(BCOS_VERSION)) {
if (BCOS_VERSION == null
|| EnumNodeVersion.BCOS_2_0_0_RC1.getVersion().equals(BCOS_VERSION)) {
if (code == PermissionDenied_RC1) {
msg = "permission denied";
} else if (code == TableNameAndAddressExist_RC1) {
Expand All @@ -69,7 +71,7 @@ public static String transferToJson(int code) throws IOException {
} else if (code == InvalidKey_RC1) {
msg = "invalid configuration entry";
}
} else if (BCOS_RC2.equals(BCOS_VERSION)) {
} else if (EnumNodeVersion.BCOS_2_0_0_RC2.getVersion().equals(BCOS_VERSION)) {
if (code == PermissionDenied) {
msg = "permission denied";
} else if (code == TableNameAndAddressExist) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/fisco/bcos/web3j/tx/Contract.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.concurrent.Semaphore;
import java.util.stream.Collectors;
import org.fisco.bcos.channel.client.TransactionSucCallback;
import org.fisco.bcos.fisco.EnumNodeVersion;
import org.fisco.bcos.web3j.abi.EventEncoder;
import org.fisco.bcos.web3j.abi.EventValues;
import org.fisco.bcos.web3j.abi.FunctionEncoder;
Expand Down Expand Up @@ -48,7 +49,7 @@ public abstract class Contract extends ManagedTransaction {

public static final String BIN_NOT_PROVIDED = "Bin file was not provided";
public static final String FUNC_DEPLOY = "deploy";
public static final String BCOS_RC1 = "2.0.0-rc1";

protected final String contractBinary;
protected String contractAddress;
protected ContractGasProvider gasProvider;
Expand Down Expand Up @@ -94,8 +95,9 @@ public static TransactionManager getTheTransactionManager(
NodeVersion.Version nodeVersion = web3j.getNodeVersion().send().getNodeVersion();
version = nodeVersion.getVersion();
supportedVersion = nodeVersion.getSupportedVersion();
if (BCOS_RC1.equals(version) || BCOS_RC1.equals(supportedVersion)) {
version = BCOS_RC1;

if (EnumNodeVersion.BCOS_2_0_0_RC1.getVersion().equals(version) || EnumNodeVersion.BCOS_2_0_0_RC1.getVersion().equals(supportedVersion)) {
version = EnumNodeVersion.BCOS_2_0_0_RC1.getVersion();
logger.info("fisco-bcos version:{}", version);
} else {
chainId = nodeVersion.getChainID();
Expand All @@ -106,7 +108,7 @@ public static TransactionManager getTheTransactionManager(
logger.error("Query fisco-bcos version failed", e);
}

return BCOS_RC1.equals(version)
return EnumNodeVersion.BCOS_2_0_0_RC1.getVersion().equals(version)
? new RawTransactionManager(web3j, credentials)
: new ExtendedRawTransactionManager(
web3j, credentials, BigInteger.valueOf(groupId), new BigInteger(chainId));
Expand Down

0 comments on commit 1150acc

Please sign in to comment.