Skip to content

Commit

Permalink
Merge pull request #69 from CESSProject/f_go_1.19
Browse files Browse the repository at this point in the history
F go 1.19
  • Loading branch information
AstaFrode authored Oct 31, 2022
2 parents 967a5e9 + 0ad36ef commit cfec59f
Show file tree
Hide file tree
Showing 35 changed files with 1,263 additions and 3,092 deletions.
52 changes: 29 additions & 23 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import (
"github.com/CESSProject/cess-bucket/internal/chain"
"github.com/CESSProject/cess-bucket/internal/logger"
. "github.com/CESSProject/cess-bucket/internal/logger"
"github.com/CESSProject/cess-bucket/internal/node"
"github.com/CESSProject/cess-bucket/internal/pattern"
"github.com/CESSProject/cess-bucket/internal/rpc"
"github.com/CESSProject/cess-bucket/internal/task"
"github.com/CESSProject/cess-bucket/tools"

"github.com/btcsuite/btcutil/base58"
Expand Down Expand Up @@ -150,7 +149,7 @@ func Command_UpdateAddress() *cobra.Command {
cc := &cobra.Command{
Use: "update_address",
Short: "Update the miner's access address",
Example: "bucket update_address ip:port[domain_name]",
Example: "bucket update_address ip:port",
Run: Command_UpdateAddress_Runfunc,
DisableFlagsInUseLine: true,
}
Expand Down Expand Up @@ -240,9 +239,9 @@ func register(api *gsrpc.SubstrateAPI) error {
txhash, err := chain.Register(
api,
configs.C.IncomeAcc,
res,
configs.C.ServiceIP,
uint16(configs.C.ServicePort),
pledgeTokens,
pattern.GetMinerAcc(),
)
if err != nil {
if err.Error() == chain.ERR_Empty {
Expand Down Expand Up @@ -327,9 +326,8 @@ func Command_State_Runfunc(cmd *cobra.Command, args []string) {
log.Printf("[err] Query error: %v\n", err)
os.Exit(1)
}

mData.Collaterals.Div(new(big.Int).SetBytes(mData.Collaterals.Bytes()), big.NewInt(1000000000000))
addr := base58.Decode(string(mData.Ip))
addr := fmt.Sprintf("%d.%d.%d.%d:%d", mData.Ip.Value[0], mData.Ip.Value[1], mData.Ip.Value[2], mData.Ip.Value[3], mData.Ip.Port)
var power, space float32
var power_unit, space_unit string
count := 0
Expand Down Expand Up @@ -461,8 +459,9 @@ func Command_Run_Runfunc(cmd *cobra.Command, args []string) {
}

// start-up
go task.Run()
rpc.Rpc_Main()
//go task.Run()
//rpc.Rpc_Main()
node.New().Run()
}

// Exit mining
Expand Down Expand Up @@ -498,7 +497,7 @@ func Command_Exit_Runfunc(cmd *cobra.Command, args []string) {
os.Exit(1)
}

//Increase deposit
// Increase deposit
func Command_Increase_Runfunc(cmd *cobra.Command, args []string) {
//Too few command line arguments
if len(os.Args) < 3 {
Expand Down Expand Up @@ -616,21 +615,24 @@ func Command_Withdraw_Runfunc(cmd *cobra.Command, args []string) {
func Command_UpdateAddress_Runfunc(cmd *cobra.Command, args []string) {
if len(os.Args) >= 3 {
data := strings.Split(os.Args[2], ":")
if len(data) == 2 {
if !tools.IsIPv4(data[0]) {
log.Printf("\x1b[%dm[ok]\x1b[0m address error\n", 42)
os.Exit(1)
}
_, err := strconv.Atoi(data[1])
if err != nil {
log.Printf("\x1b[%dm[ok]\x1b[0m address error\n", 42)
os.Exit(1)
}
if len(data) != 2 {
log.Printf("\x1b[%dm[err]\x1b[0m You should enter something like 'bucket address ip:port[domain_name]'\n", 41)
os.Exit(1)
}
if !tools.IsIPv4(data[0]) {
log.Printf("\x1b[%dm[ok]\x1b[0m address error\n", 42)
os.Exit(1)
}
_, err := strconv.Atoi(data[1])
if err != nil {
log.Printf("\x1b[%dm[ok]\x1b[0m address error\n", 42)
os.Exit(1)
}

//Parse command arguments and configuration file
parseFlags(cmd)

txhash, err := chain.UpdateAddress(configs.C.SignatureAcc, base58.Encode([]byte(os.Args[2])))
txhash, err := chain.UpdateAddress(configs.C.SignatureAcc, data[0], data[1])
if err != nil {
if err.Error() == chain.ERR_Empty {
log.Println("[err] Please check your wallet balance.")
Expand Down Expand Up @@ -791,9 +793,13 @@ func parseProfile() {
log.Printf("[err] %v\n", err)
os.Exit(1)
}
configs.Shared_g = data.Shared_g
configs.Shared_g = make([]byte, 128)
configs.Spk = make([]byte, 128)
for i := 0; i < 128; i++ {
configs.Shared_g[i] = byte(data.Shared_g[i])
configs.Spk[i] = byte(data.Spk[i])
}
configs.Shared_params = data.Shared_params
configs.Spk = data.Spk
}
pattern.SetMinerAcc(acc)
pattern.SetMinerSignAddr(configs.C.IncomeAcc)
Expand Down
19 changes: 10 additions & 9 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package configs
import "time"

// type and version
const Version = "CESS-Bucket v0.5.2"
const Version = "CESS-Bucket v0.5.3"

// return code
const (
Expand All @@ -22,14 +22,15 @@ const (
)

const (
Space_1GB = 1024 * 1024 * 1024 // 1GB
Space_1MB = 1024 * 1024 // 1MB
ByteSize_1Kb = 1024 // 1KB
TimeToWaitEvents_S = 20 //The time to wait for the event, in seconds
TokenAccuracy = "000000000000" //Unit precision of CESS coins
ExitColling = 28800 //blocks
BlockSize = 1024 * 1024 //1MB
ScanBlockSize = 512 * 1024 //512KB
SIZE_1KiB = 1024
SIZE_1MiB = SIZE_1KiB * 1024 // 1MB
SIZE_1GiB = SIZE_1MiB * 1024
FillerSize = 8 * SIZE_1MiB
TimeToWaitEvents_S = 20 //The time to wait for the event, in seconds
TokenAccuracy = "000000000000" //Unit precision of CESS coins
ExitColling = 28800 //blocks
BlockSize = 1024 * 1024 //1MB
ScanBlockSize = 512 * 1024 //512KB
// the time to wait for the event, in seconds
TimeToWaitEvents = time.Duration(time.Second * 15)
)
Expand Down
23 changes: 3 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,64 +7,47 @@ require (
github.com/Nik-U/pbc v0.0.0-20181205041846-3e516ca0c5d6
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.5
github.com/deckarep/golang-set v1.8.0
github.com/gin-contrib/cors v1.4.0
github.com/gin-gonic/gin v1.8.1
github.com/golang/protobuf v1.5.2
github.com/gorilla/websocket v1.5.0
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/pkg/errors v0.9.1
github.com/shirou/gopsutil v3.21.11+incompatible
github.com/soheilhy/cmux v0.1.5
github.com/spf13/cobra v1.5.0
github.com/spf13/viper v1.12.0
go.uber.org/zap v1.23.0
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
google.golang.org/protobuf v1.28.1
storj.io/common v0.0.0-20220902050723-654fd98b53c6
)

require (
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/base58 v1.0.4 // indirect
github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
github.com/ethereum/go-ethereum v1.10.17 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.10.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/goccy/go-json v0.9.7 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/pierrec/xxHash v0.1.5 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
github.com/vedhavyas/go-subkey v1.0.3 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
Expand Down
Loading

0 comments on commit cfec59f

Please sign in to comment.