Skip to content

Commit 8e8de21

Browse files
authored
add tx_gar_price systemConfig to java sdk (#877)
* add tx_gar_price systemConfig to java sdk
1 parent 19f423e commit 8e8de21

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/java/org/fisco/bcos/sdk/v3/client/ClientImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,15 @@ public void getPbftViewAsync(String node, RespCallback<PbftView> callback) {
983983

984984
@Override
985985
public SystemConfig getSystemConfigByKey(String key) {
986+
if (key.equals(SystemConfigService.TX_GAS_PRICE)) {
987+
String gasPrice =
988+
this.getSystemConfigByKey(nodeToSendRequest, key).getSystemConfig().getValue();
989+
BigInteger gasPriceValue =
990+
BigInteger.valueOf(Integer.parseInt(Hex.trimPrefix(gasPrice), 16));
991+
this.getSystemConfigByKey(nodeToSendRequest, key)
992+
.getSystemConfig()
993+
.setValue(gasPriceValue.toString());
994+
}
986995
return this.getSystemConfigByKey(nodeToSendRequest, key);
987996
}
988997

src/main/java/org/fisco/bcos/sdk/v3/contract/precompiled/sysconfig/SystemConfigService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.fisco.bcos.sdk.v3.model.TransactionReceipt;
3333
import org.fisco.bcos.sdk.v3.transaction.codec.decode.ReceiptParser;
3434
import org.fisco.bcos.sdk.v3.transaction.model.exception.ContractException;
35+
import org.fisco.bcos.sdk.v3.utils.Numeric;
3536
import org.slf4j.Logger;
3637
import org.slf4j.LoggerFactory;
3738

@@ -40,6 +41,7 @@ public class SystemConfigService {
4041
private final Client client;
4142
public static final String TX_COUNT_LIMIT = "tx_count_limit";
4243
public static final String TX_GAS_LIMIT = "tx_gas_limit";
44+
public static final String TX_GAS_PRICE = "tx_gas_price";
4345
public static final String CONSENSUS_PERIOD = "consensus_leader_period";
4446
public static final String AUTH_STATUS = "auth_check_status";
4547
public static final String COMPATIBILITY_VERSION = "compatibility_version";
@@ -53,6 +55,7 @@ public class SystemConfigService {
5355
predicateMap.put(AUTH_STATUS, value -> value.compareTo(BigInteger.ZERO) >= 0);
5456
predicateMap.put(
5557
TX_GAS_LIMIT, value -> value.compareTo(BigInteger.valueOf(TX_GAS_LIMIT_MIN)) >= 0);
58+
predicateMap.put(TX_GAS_PRICE, value -> value.compareTo(BigInteger.ZERO) >= 0);
5659
}
5760

5861
public SystemConfigService(Client client, CryptoKeyPair credential) {
@@ -83,6 +86,10 @@ public RetCode setValueByKey(String key, String value) throws ContractException
8386
&& SystemConfigFeature.fromString(key) == null) {
8487
throw new ContractException("Unsupported feature key: [" + key + "]");
8588
}
89+
if (key.equals(TX_GAS_PRICE)) {
90+
BigInteger gasPrice = new BigInteger(value);
91+
value = Numeric.toHexString(gasPrice);
92+
}
8693

8794
TransactionReceipt receipt = systemConfigPrecompiled.setValueByKey(key, value);
8895
return ReceiptParser.parseTransactionReceipt(

0 commit comments

Comments
 (0)