Skip to content

Commit

Permalink
Modified readpool to single balance configuration (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamrz1 authored Jun 13, 2022
1 parent a819a39 commit a13bdba
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 78 deletions.
26 changes: 4 additions & 22 deletions cmd/readpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ var rpCreate = &cobra.Command{

func printReadPoolInfo(stat *sdk.ReadPool) {
fmt.Println()
fmt.Println(" balance for own allocations: ", stat.OwnerBalance)
fmt.Println(" balance for other allocations: ", stat.VisitorBalance)
fmt.Println(" balance : ", stat.Balance)
fmt.Println()
}

Expand Down Expand Up @@ -62,7 +61,7 @@ var rpInfo = &cobra.Command{
log.Fatalf("Failed to get read pool info: %v", err)
}

if info.OwnerBalance == 0 && info.VisitorBalance == 0 {
if info.Balance == 0 {
fmt.Println("no tokens locked")
return
}
Expand Down Expand Up @@ -104,14 +103,7 @@ var rpLock = &cobra.Command{
}
}

isOwner := true
if flags.Changed("owner") {
if isOwner, err = flags.GetBool("owner"); err != nil {
log.Fatal("invalid 'owner' flag: ", err)
}
}

_, _, err = sdk.ReadPoolLock(zcncore.ConvertToValue(tokens), zcncore.ConvertToValue(fee), isOwner)
_, _, err = sdk.ReadPoolLock(zcncore.ConvertToValue(tokens), zcncore.ConvertToValue(fee))
if err != nil {
log.Fatalf("Failed to lock tokens in read pool: %v", err)
}
Expand Down Expand Up @@ -140,14 +132,7 @@ var rpUnlock = &cobra.Command{
}
}

isOwner := true
if flags.Changed("owner") {
if isOwner, err = flags.GetBool("owner"); err != nil {
log.Fatal("invalid 'owner' flag: ", err)
}
}

_, _, err = sdk.ReadPoolUnlock(zcncore.ConvertToValue(fee), isOwner)
_, _, err = sdk.ReadPoolUnlock(zcncore.ConvertToValue(fee))
if err != nil {
log.Fatalf("Failed to unlock tokens in read pool: %v", err)
}
Expand All @@ -165,11 +150,8 @@ func init() {

rpLock.PersistentFlags().Float64("tokens", 0.0,
"lock tokens number, required")
rpLock.PersistentFlags().Bool("owner", true,
"lock tokens for owned allocations (false = visiting allocations), optional")
rpLock.PersistentFlags().Float64("fee", 0.0,
"transaction fee, default 0")

rpLock.MarkFlagRequired("tokens")

rpUnlock.PersistentFlags().Float64("fee", 0.0,
Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.8.5-0.20220606064534-3b9b68a3a494
github.com/0chain/gosdk v1.8.5-0.20220612164456-ee2166bf0a73
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.4.0
Expand All @@ -13,14 +13,14 @@ require (
)

require (
github.com/btcsuite/btcd v0.22.0-beta.0.20220428234604-a86222c92d7d // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect
github.com/btcsuite/btcd/btcutil v1.1.0 // indirect
github.com/btcsuite/btcd v0.23.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/btcsuite/btcd/btcutil v1.1.1 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/ethereum/go-ethereum v1.10.17 // indirect
github.com/fsnotify/fsnotify v1.5.3 // indirect
github.com/ethereum/go-ethereum v1.10.18 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/google/uuid v1.3.0 // indirect
Expand All @@ -37,30 +37,30 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.11.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/tklauser/numcpus v0.5.0 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.dedis.ch/fixbuf v1.0.3 // indirect
go.dedis.ch/kyber/v3 v3.0.13 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // 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
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// temporary, for development
Expand Down
Loading

0 comments on commit a13bdba

Please sign in to comment.