Skip to content

Commit

Permalink
update sdk, add InitExtrinsicsName (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
AstaFrode committed Jun 19, 2024
1 parent 3755aac commit aae53f8
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 20 deletions.
9 changes: 8 additions & 1 deletion cmd/console/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@ func Command_Claim_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

txhash, err := cli.ReceiveReward()
err = cli.InitExtrinsicsName()
if err != nil {
out.Err("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
}

txhash, _, err := cli.ReceiveReward()
if err != nil {
out.Err(err.Error())
if txhash == "" {
out.Err(err.Error())
os.Exit(1)
Expand Down
6 changes: 6 additions & 0 deletions cmd/console/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ func Command_Exit_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

err = cli.InitExtrinsicsName()
if err != nil {
out.Err("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
}

txhash, err := cli.MinerExitPrep()
if err != nil {
if txhash == "" {
Expand Down
12 changes: 12 additions & 0 deletions cmd/console/increase.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ func increaseStakingCmd_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

err = cli.InitExtrinsicsName()
if err != nil {
out.Err("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
}

txhash, err := cli.IncreaseCollateral(cli.GetSignatureAccPulickey(), os.Args[3])
if err != nil {
if txhash == "" {
Expand Down Expand Up @@ -146,6 +152,12 @@ func increaseSpaceCmd_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

err = cli.InitExtrinsicsName()
if err != nil {
out.Err("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
}

accInfo, err := cli.QueryAccountInfo(cli.GetSignatureAcc(), -1)
if err != nil {
if err.Error() != chain.ERR_Empty {
Expand Down
15 changes: 11 additions & 4 deletions cmd/console/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ func runCmd(cmd *cobra.Command, args []string) {
}
defer cli.Close()

err = cli.InitExtrinsicsName()
if err != nil {
out.Err("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
}

runtime.SetCurrentRpc(cli.GetCurrentRpcAddr())
runtime.SetChainStatus(true)
runtime.SetMinerSignAcc(cli.GetSignatureAcc())
Expand Down Expand Up @@ -335,8 +341,8 @@ func runCmd(cmd *cobra.Command, args []string) {
restoreCh := make(chan bool, 1)
restoreCh <- true

tick_block := time.NewTicker(chain.BlockInterval)
defer tick_block.Stop()
tick_29s := time.NewTicker(time.Second * time.Duration(29))
defer tick_29s.Stop()

tick_Minute := time.NewTicker(time.Second * time.Duration(57))
defer tick_Minute.Stop()
Expand All @@ -347,7 +353,7 @@ func runCmd(cmd *cobra.Command, args []string) {
out.Ok("Service started successfully")
for {
select {
case <-tick_block.C:
case <-tick_29s.C:
chainState = cli.GetRpcState()
if !chainState {
runtime.SetChainStatus(false)
Expand Down Expand Up @@ -378,6 +384,7 @@ func runCmd(cmd *cobra.Command, args []string) {
}

case <-tick_Minute.C:
chainState = cli.GetRpcState()
if !chainState {
break
}
Expand Down Expand Up @@ -425,7 +432,7 @@ func runCmd(cmd *cobra.Command, args []string) {
}

// go n.reportLogsMgt(ch_reportLogs)

chainState = cli.GetRpcState()
if !chainState {
break
}
Expand Down
1 change: 1 addition & 0 deletions cmd/console/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func Command_State_Runfunc(cmd *cobra.Command, args []string) {
}

minerInfo.Collaterals.Div(new(big.Int).SetBytes(minerInfo.Collaterals.Bytes()), big.NewInt(configs.TokenTCESS))
minerInfo.Debt.Div(new(big.Int).SetBytes(minerInfo.Debt.Bytes()), big.NewInt(configs.TokenTCESS))

beneficiaryAcc, _ := sutils.EncodePublicKeyAsCessAccount(minerInfo.BeneficiaryAccount[:])

Expand Down
6 changes: 6 additions & 0 deletions cmd/console/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func updateEarningsAccount(cmd *cobra.Command) {
}
defer cli.Close()

err = cli.InitExtrinsicsName()
if err != nil {
out.Err("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
}

txhash, err := cli.UpdateBeneficiary(os.Args[3])
if err != nil {
if txhash == "" {
Expand Down
6 changes: 6 additions & 0 deletions cmd/console/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ func Command_Withdraw_Runfunc(cmd *cobra.Command, args []string) {
}
defer cli.Close()

err = cli.InitExtrinsicsName()
if err != nil {
out.Err("The rpc address does not match the software version, please check the rpc address.")
os.Exit(1)
}

txhash, err := cli.MinerWithdraw()
if err != nil {
if txhash == "" {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/CESSProject/cess-miner
go 1.20

require (
github.com/CESSProject/cess-go-sdk v0.5.1-0.20240604024323-4bb5b057a452
github.com/CESSProject/cess-go-sdk v0.5.1-0.20240613063000-6fbbc78af812
github.com/CESSProject/cess_pois v0.5.15
github.com/CESSProject/p2p-go v0.3.14
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/CESSProject/cess-go-sdk v0.5.1-0.20240604024323-4bb5b057a452 h1:gVQoivK44Cn3asnCgEFj1XLELFzbfC5TdJt3tq4UCD0=
github.com/CESSProject/cess-go-sdk v0.5.1-0.20240604024323-4bb5b057a452/go.mod h1:9BGRFkU3Zc5CYqK9EIz3DY14MjDg6a0bA1DWgMk3qFc=
github.com/CESSProject/cess-go-sdk v0.5.1-0.20240613063000-6fbbc78af812 h1:J67nH3JsoeRXX2CO/7wM8YuE2BRN8fpl/si/c3bdpak=
github.com/CESSProject/cess-go-sdk v0.5.1-0.20240613063000-6fbbc78af812/go.mod h1:9BGRFkU3Zc5CYqK9EIz3DY14MjDg6a0bA1DWgMk3qFc=
github.com/CESSProject/cess_pois v0.5.15 h1:oQH8xEtxVzB+SeI+gNS6iSeFgjb/xDAsmgyuoF3al28=
github.com/CESSProject/cess_pois v0.5.15/go.mod h1:rztEZjjG+MbKzVgh5WtQcZc/7ZDkBvDNABc7Em8BKPc=
github.com/CESSProject/p2p-go v0.3.14 h1:t7xLWTC8C+tuELtD6f2k4Ds6Z0zulMA0v83ONTDTthw=
Expand Down
15 changes: 3 additions & 12 deletions node/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,9 @@ func Subscribe(ctx context.Context, h host.Host, minerRecord MinerRecord, bootno
return
}

if strings.Contains(bootnode, "12D3KooWRm2sQg65y2ZgCUksLsjWmKbBtZ4HRRsGLxbN76XTtC8T") {
room = fmt.Sprintf("%s-12D3KooWRm2sQg65y2ZgCUksLsjWmKbBtZ4HRRsGLxbN76XTtC8T", core.NetworkRoom)
} else if strings.Contains(bootnode, "12D3KooWEGeAp1MvvUrBYQtb31FE1LPg7aHsd1LtTXn6cerZTBBd") {
room = fmt.Sprintf("%s-12D3KooWEGeAp1MvvUrBYQtb31FE1LPg7aHsd1LtTXn6cerZTBBd", core.NetworkRoom)
} else if strings.Contains(bootnode, "12D3KooWGDk9JJ5F6UPNuutEKSbHrTXnF5eSn3zKaR27amgU6o9S") {
room = fmt.Sprintf("%s-12D3KooWGDk9JJ5F6UPNuutEKSbHrTXnF5eSn3zKaR27amgU6o9S", core.NetworkRoom)
} else if strings.Contains(bootnode, "12D3KooWS8a18xoBzwkmUsgGBctNo6QCr6XCpUDR946mTBBUTe83") {
room = fmt.Sprintf("%s-12D3KooWS8a18xoBzwkmUsgGBctNo6QCr6XCpUDR946mTBBUTe83", core.NetworkRoom)
} else if strings.Contains(bootnode, "12D3KooWDWeiiqbpNGAqA5QbDTdKgTtwX8LCShWkTpcyxpRf2jA9") {
room = fmt.Sprintf("%s-12D3KooWDWeiiqbpNGAqA5QbDTdKgTtwX8LCShWkTpcyxpRf2jA9", core.NetworkRoom)
} else if strings.Contains(bootnode, "12D3KooWNcTWWuUWKhjTVDF1xZ38yCoHXoF4aDjnbjsNpeVwj33U") {
room = fmt.Sprintf("%s-12D3KooWNcTWWuUWKhjTVDF1xZ38yCoHXoF4aDjnbjsNpeVwj33U", core.NetworkRoom)
data := strings.Split(bootnode, "/p2p/")
if len(data) > 1 {
room = fmt.Sprintf("%s-%s", core.NetworkRoom, data[len(data)-1])
} else {
room = core.NetworkRoom
}
Expand Down

0 comments on commit aae53f8

Please sign in to comment.