Skip to content

Commit b46d248

Browse files
authored
Merge pull request #430 from morebtcg/release-3.1.0
Add dag flag
2 parents 12be5c9 + 6c864e4 commit b46d248

File tree

4 files changed

+47
-21
lines changed

4 files changed

+47
-21
lines changed

sdk-service/src/main/java/org/fisco/bcos/sdk/client/Client.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@ static Client build(ConfigOption configOption) throws JniException {
103103
* @return the groupId
104104
*/
105105
String getChainId();
106+
106107
/** */
107108
ConfigOption getConfigOption();
108109

110+
public boolean getDAG();
111+
112+
public void setDAG(boolean dag);
113+
109114
// ------------------------- rpc interface begin ------------------------------------------
110115

111116
/**
@@ -555,6 +560,7 @@ void getTransactionReceiptAsync(
555560
GroupPeers getGroupPeers();
556561

557562
void getGroupPeersAsync(RespCallback<GroupPeers> callback);
563+
558564
/**
559565
* Peer operation: async get connected peers
560566
*

sdk-service/src/main/java/org/fisco/bcos/sdk/client/ClientImpl.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public class ClientImpl implements Client {
5353
private Boolean smCrypto;
5454
// ------------basic group info --------------
5555

56+
// ------------ runtime info -----------------
57+
private boolean dag = false;
58+
// ------------ runtime info -----------------
59+
5660
private long blockNumber = 0;
5761

5862
private BcosGroupInfo.GroupInfo groupInfo;
@@ -157,6 +161,16 @@ public Boolean getSmCrypto() {
157161
return this.smCrypto;
158162
}
159163

164+
@Override
165+
public boolean getDAG() {
166+
return this.dag;
167+
}
168+
169+
@Override
170+
public void setDAG(boolean dag) {
171+
this.dag = dag;
172+
}
173+
160174
@Override
161175
public CryptoSuite getCryptoSuite() {
162176
return this.cryptoSuite;

sdk-service/src/main/java/org/fisco/bcos/sdk/client/protocol/model/tars/Transaction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313

1414
@TarsStruct
1515
public class Transaction {
16+
public static final int EVM_ABI_CODEC = 0x1;
1617
public static final int LIQUID_SCALE_CODEC = 0x2;
18+
public static final int DAG = 0x4;
1719
public static final int LIQUID_CREATE = 0x8;
1820

1921
@TarsStructProperty(order = 1, isRequire = false)

sdk-transaction/src/main/java/org/fisco/bcos/sdk/contract/Contract.java

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.*;
2323
import java.util.stream.Collectors;
2424
import org.fisco.bcos.sdk.client.Client;
25+
import org.fisco.bcos.sdk.client.protocol.model.tars.Transaction;
2526
import org.fisco.bcos.sdk.client.protocol.response.Call;
2627
import org.fisco.bcos.sdk.codec.ABICodec;
2728
import org.fisco.bcos.sdk.codec.ABICodecException;
@@ -204,6 +205,24 @@ private static <T extends Contract> T create(
204205
return contract;
205206
}
206207

208+
private int generateTransactionAttribute(String funcName) {
209+
int attribute = 0;
210+
if (client.isWASM()) {
211+
attribute = LIQUID_SCALE_CODEC;
212+
if (funcName == FUNC_DEPLOY) {
213+
attribute |= LIQUID_CREATE;
214+
}
215+
} else {
216+
attribute |= Transaction.EVM_ABI_CODEC;
217+
}
218+
219+
if (client.getDAG()) {
220+
attribute |= Transaction.DAG;
221+
}
222+
223+
return attribute;
224+
}
225+
207226
public String getContractAddress() {
208227
return this.contractAddress;
209228
}
@@ -292,13 +311,8 @@ protected List<Type> executeCallWithMultipleValueReturn(Function function)
292311

293312
protected void asyncExecuteTransaction(
294313
byte[] data, String funName, TransactionCallback callback) {
295-
int txAttribute = 0;
296-
if (client.isWASM()) {
297-
txAttribute = LIQUID_SCALE_CODEC;
298-
if (funName == FUNC_DEPLOY) {
299-
txAttribute |= LIQUID_CREATE;
300-
}
301-
}
314+
int txAttribute = generateTransactionAttribute(funName);
315+
302316
this.transactionProcessor.sendTransactionAsync(
303317
this.contractAddress, data, this.credential, txAttribute, callback);
304318
}
@@ -313,13 +327,8 @@ protected TransactionReceipt executeTransaction(Function function) {
313327
}
314328

315329
protected TransactionReceipt executeTransaction(byte[] data, String functionName) {
316-
int txAttribute = 0;
317-
if (client.isWASM()) {
318-
txAttribute = LIQUID_SCALE_CODEC;
319-
if (functionName == FUNC_DEPLOY) {
320-
txAttribute |= LIQUID_CREATE;
321-
}
322-
}
330+
int txAttribute = generateTransactionAttribute(functionName);
331+
323332
return this.transactionProcessor.sendTransactionAndGetReceipt(
324333
this.contractAddress, data, this.credential, txAttribute);
325334
}
@@ -348,13 +357,8 @@ public TransactionReceipt.Logs getLog() {
348357
}
349358

350359
protected String createSignedTransaction(Function function) {
351-
int txAttribute = 0;
352-
if (client.isWASM()) {
353-
txAttribute = LIQUID_SCALE_CODEC;
354-
if (function.getName() == FUNC_DEPLOY) {
355-
txAttribute |= LIQUID_CREATE;
356-
}
357-
}
360+
int txAttribute = generateTransactionAttribute(function.getName());
361+
358362
return this.createSignedTransaction(
359363
this.contractAddress, this.functionEncoder.encode(function), txAttribute);
360364
}

0 commit comments

Comments
 (0)