Skip to content

Commit 1910388

Browse files
author
Jayash Satolia
committed
Update to staging 1.18
1 parent 94a1d3a commit 1910388

File tree

5 files changed

+15
-129
lines changed

5 files changed

+15
-129
lines changed

cmd/mn-delete.go

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ package cmd
22

33
import (
44
"fmt"
5-
"log"
6-
"strconv"
7-
"strings"
8-
"sync"
9-
105
"github.com/0chain/gosdk/zcncore"
116
"github.com/spf13/cobra"
7+
"log"
128
)
139

1410
var minerDelete = &cobra.Command{
@@ -31,46 +27,12 @@ var minerDelete = &cobra.Command{
3127
log.Fatal(err)
3228
}
3329

34-
var (
35-
wg sync.WaitGroup
36-
statusBar = &ZCNStatus{wg: &wg}
37-
)
38-
txn, err := zcncore.NewTransaction(statusBar, 0, nonce)
30+
hash, _, _, _, err := zcncore.DeleteMiner(id)
3931
if err != nil {
40-
log.Fatal(err)
41-
}
42-
wg.Add(1)
43-
err = txn.MinerSCDeleteMiner(id)
44-
if err != nil {
45-
log.Fatal(err)
46-
}
47-
wg.Wait()
48-
49-
if !statusBar.success {
50-
log.Fatal("fatal:", statusBar.errMsg)
32+
log.Fatal("Delete miner failed : ", err.Error())
5133
}
5234

53-
statusBar.success = false
54-
wg.Add(1)
55-
if err = txn.Verify(); err != nil {
56-
log.Fatal(err)
57-
}
58-
wg.Wait()
59-
60-
if statusBar.success {
61-
switch txn.GetVerifyConfirmationStatus() {
62-
case zcncore.ChargeableError:
63-
ExitWithError("\n", strings.Trim(txn.GetVerifyOutput(), "\""))
64-
case zcncore.Success:
65-
fmt.Println("delete :", id)
66-
default:
67-
ExitWithError("\ndelete " + id + " failed. Unknown status code: " +
68-
strconv.Itoa(int(txn.GetVerifyConfirmationStatus())))
69-
}
70-
return
71-
} else {
72-
log.Fatal("fatal:", statusBar.errMsg)
73-
}
35+
fmt.Println("delete miner success with transaction hash : ", hash)
7436
},
7537
}
7638

cmd/sh-delete.go

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ package cmd
22

33
import (
44
"fmt"
5-
"log"
6-
"strconv"
7-
"strings"
8-
"sync"
9-
105
"github.com/0chain/gosdk/zcncore"
116
"github.com/spf13/cobra"
7+
"log"
128
)
139

1410
var sharderDelete = &cobra.Command{
@@ -31,46 +27,12 @@ var sharderDelete = &cobra.Command{
3127
log.Fatal(err)
3228
}
3329

34-
var (
35-
wg sync.WaitGroup
36-
statusBar = &ZCNStatus{wg: &wg}
37-
)
38-
txn, err := zcncore.NewTransaction(statusBar, 0, nonce)
30+
hash, _, _, _, err := zcncore.DeleteSharder(id)
3931
if err != nil {
40-
log.Fatal(err)
41-
}
42-
wg.Add(1)
43-
err = txn.MinerSCDeleteSharder(id)
44-
if err != nil {
45-
log.Fatal(err)
46-
}
47-
wg.Wait()
48-
49-
if !statusBar.success {
50-
log.Fatal("fatal:", statusBar.errMsg)
32+
log.Fatal("Delete sharder failed : ", err.Error())
5133
}
5234

53-
statusBar.success = false
54-
wg.Add(1)
55-
if err = txn.Verify(); err != nil {
56-
log.Fatal(err)
57-
}
58-
wg.Wait()
59-
60-
if statusBar.success {
61-
switch txn.GetVerifyConfirmationStatus() {
62-
case zcncore.ChargeableError:
63-
ExitWithError("\n", strings.Trim(txn.GetVerifyOutput(), "\""))
64-
case zcncore.Success:
65-
fmt.Println("delete :", id)
66-
default:
67-
ExitWithError("\ndelete " + id + " failed. Unknown status code: " +
68-
strconv.Itoa(int(txn.GetVerifyConfirmationStatus())))
69-
}
70-
return
71-
} else {
72-
log.Fatal("fatal:", statusBar.errMsg)
73-
}
35+
fmt.Println("delete sharder success with transaction hash : ", hash)
7436
},
7537
}
7638

cmd/vc-add.go

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ package cmd
22

33
import (
44
"fmt"
5-
"log"
6-
"strconv"
7-
"strings"
8-
"sync"
9-
105
"github.com/0chain/gosdk/zboxcore/sdk"
116
"github.com/0chain/gosdk/zcncore"
127
"github.com/spf13/cobra"
8+
"log"
139
)
1410

1511
var providerRegister = &cobra.Command{
@@ -51,46 +47,12 @@ var providerRegister = &cobra.Command{
5147
log.Fatalf("unknown provider type: %v", nodeType)
5248
}
5349

54-
var (
55-
wg sync.WaitGroup
56-
statusBar = &ZCNStatus{wg: &wg}
57-
)
58-
txn, err := zcncore.NewTransaction(statusBar, 0, nonce)
50+
hash, _, _, _, err := zcncore.VcRegisterNode(id, pt)
5951
if err != nil {
60-
log.Fatal(err)
61-
}
62-
wg.Add(1)
63-
err = txn.MinerSCVCAdd(id, pt)
64-
if err != nil {
65-
log.Fatal(err)
66-
}
67-
wg.Wait()
68-
69-
if !statusBar.success {
70-
log.Fatal("fatal:", statusBar.errMsg)
52+
log.Fatal("Vc register node : ", err)
7153
}
7254

73-
statusBar.success = false
74-
wg.Add(1)
75-
if err = txn.Verify(); err != nil {
76-
log.Fatal(err)
77-
}
78-
wg.Wait()
79-
80-
if statusBar.success {
81-
switch txn.GetVerifyConfirmationStatus() {
82-
case zcncore.ChargeableError:
83-
ExitWithError("\n", strings.Trim(txn.GetVerifyOutput(), "\""))
84-
case zcncore.Success:
85-
fmt.Println("vc add: ", id)
86-
default:
87-
ExitWithError("\nvc add " + id + " failed. Unknown status code: " +
88-
strconv.Itoa(int(txn.GetVerifyConfirmationStatus())))
89-
}
90-
return
91-
} else {
92-
log.Fatal("fatal:", statusBar.errMsg)
93-
}
55+
fmt.Println("vc add success with transaction hash : ", hash)
9456
},
9557
}
9658

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22.0
55
toolchain go1.22.5
66

77
require (
8-
github.com/0chain/gosdk v1.18.0
8+
github.com/0chain/gosdk v1.18.7-0.20241121161351-98da16fe3ffb
99
github.com/ethereum/go-ethereum v1.13.2
1010
github.com/icza/bitio v1.1.0
1111
github.com/olekukonko/tablewriter v0.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ github.com/0chain/common v1.18.3 h1:42dYOv2KyMTSanuS67iDtfv+ErbSRqR8NJ3MG72MwaI=
4040
github.com/0chain/common v1.18.3/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw=
4141
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
4242
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
43-
github.com/0chain/gosdk v1.18.0 h1:6mSiUFb4liT50wdsx59tEWMHKWkKQUlZT91ouQAeKcc=
44-
github.com/0chain/gosdk v1.18.0/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
43+
github.com/0chain/gosdk v1.18.7-0.20241121161351-98da16fe3ffb h1:d4j9NFcGHkFeG3xVaWaOt70njGslb+18v+GMhL5ukdk=
44+
github.com/0chain/gosdk v1.18.7-0.20241121161351-98da16fe3ffb/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
4545
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4646
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
4747
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=

0 commit comments

Comments
 (0)