Skip to content

Commit 5fc0380

Browse files
committed
delete subchain interface
1 parent 4d2f305 commit 5fc0380

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

chainsql/src/main/java/com/peersafe/base/core/formats/TxFormat.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ public String name() {
222222
Field.PeerList, Requirement.REQUIRED,
223223
Field.SchemaID, Requirement.REQUIRED);
224224

225+
static public TxFormat SchemaDelete = new TxFormat(
226+
TransactionType.SchemaDelete,
227+
Field.SchemaID, Requirement.REQUIRED);
228+
229+
225230
static public TxFormat Authorize = new TxFormat(
226231
TransactionType.Authorize,
227232
Field.Account, Requirement.REQUIRED,

chainsql/src/main/java/com/peersafe/chainsql/core/Chainsql.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ JSONObject prepareSigned() {
437437
switch(txType_){
438438
case SchemaCreate:
439439
case SchemaModify:
440+
case SchemaDelete:
440441
case FreezeAccount:
441442
{
442443
payment = toTransaction(mTxJson,txType_);
@@ -627,7 +628,6 @@ public Chainsql createSchema(JSONObject schemaInfo) throws Exception{
627628
return this;
628629
}
629630

630-
631631
public Chainsql modifySchema(SchemaOpType type,JSONObject schemaInfo) throws Exception{
632632

633633
boolean bValid = schemaInfo.has("SchemaID") && schemaInfo.has("Validators") && schemaInfo.has("PeerList");
@@ -684,6 +684,22 @@ public Chainsql modifySchema(SchemaOpType type,JSONObject schemaInfo) throws E
684684
return this;
685685
}
686686

687+
public Chainsql deleteSchema(String schemaID) throws Exception{
688+
689+
if(schemaID == null || schemaID.equals(""))
690+
throw new Exception("Invalid schemaInfo parameter");
691+
692+
this.txType_ = TransactionType.SchemaDelete;
693+
694+
JSONObject params = new JSONObject();
695+
696+
params.put("Account", this.connection.address);
697+
params.put("SchemaID",schemaID);
698+
699+
this.mTxJson = params;
700+
return this;
701+
}
702+
687703

688704

689705
private Chainsql createTable(String name, List<String> rawList, JSONObject operationRule,boolean confidential) {

chainsql/src/test/java/com/peersafe/chainsql/core/ChainsqlTest.java

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public class ChainsqlTest extends TestCase {
3939

4040

4141
public void setUp() throws Exception {
42-
// try{
43-
// c.connect("ws://192.168.29.69:16006");
44-
// c.as(rootAddress, rootSecret);
45-
// }catch (Exception e){
46-
// c.disconnect();
47-
// e.printStackTrace();
48-
// Assert.fail();
49-
// }
42+
try{
43+
c.connect("ws://localhost:6006");
44+
c.as(rootAddress, rootSecret);
45+
}catch (Exception e){
46+
c.disconnect();
47+
e.printStackTrace();
48+
Assert.fail();
49+
}
5050
}
5151

5252
public void tearDown() throws Exception {
@@ -457,6 +457,24 @@ public void testModifySchema() {
457457

458458
}
459459

460+
public void testDeleteSchema() {
461+
462+
try{
463+
String schemaID = "B4BC6A49F5A64AE0F4AA205DB92C2AD85EEE67F7D5977C83DB6D16F00A8FA08D";
464+
// SchemaOpType
465+
JSONObject obj = c.deleteSchema(schemaID).submit(Submit.SyncCond.validate_success);
466+
467+
System.out.println(obj);
468+
469+
}catch (Exception e){
470+
471+
e.printStackTrace();
472+
Assert.fail();
473+
}
474+
475+
}
476+
477+
460478
public void testGetSchemaList(){
461479
try{
462480

0 commit comments

Comments
 (0)