Skip to content

Commit

Permalink
TODO: commented out missing datastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
bbist committed Sep 9, 2021
1 parent 7982665 commit de2f983
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 42 deletions.
8 changes: 4 additions & 4 deletions cmd/getallocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ var getallocationCmd = &cobra.Command{
fmt.Println(" challenge_reward:", common.Balance(d.ChallengeReward), "(on challenge passed)")
fmt.Println(" final_reward: ", common.Balance(d.FinalReward), "(if finalized)")
fmt.Println(" terms: (allocation related terms)")
fmt.Println(" read_price: ", d.Terms.ReadPrice, "tok / GB (by 64KB chunks)")
fmt.Println(" write_price: ", d.Terms.WritePrice, "tok / GB")
fmt.Println(" read_price: ", d.Terms.ReadPrice, "/ GB (by 64KB chunks)")
fmt.Println(" write_price: ", d.Terms.WritePrice, "/ GB")
fmt.Println(" min_lock_demand: ", d.Terms.MinLockDemand*100, "%")
fmt.Println(" max_offer_duration: ", d.Terms.MaxOfferDuration)
fmt.Println(" challenge_completion_time:", d.Terms.ChallengeCompletionTime)
Expand Down Expand Up @@ -160,9 +160,9 @@ var getallocationCmd = &cobra.Command{

fmt.Println(" price:")
fmt.Println(" time_unit: ", alloc.TimeUnit)
fmt.Println(" read_price: ", downloadCostFor1GB(alloc), "tok / GB (by 64KB)")
fmt.Println(" read_price: ", downloadCostFor1GB(alloc), "/ GB (by 64KB)")
fmt.Println(" write_price:", uploadCostFor1GB(alloc),
fmt.Sprintf("tok / GB / %s", alloc.TimeUnit))
fmt.Sprintf("/ GB / %s", alloc.TimeUnit))
return
},
}
Expand Down
80 changes: 42 additions & 38 deletions cmd/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,40 @@ import (
"github.com/spf13/cobra"
)

func printStorageSCConfig(conf *sdk.StorageSCConfig) {
fmt.Println("min_alloc_size: ", conf.MinAllocSize)
fmt.Println("min_alloc_duration: ", conf.MinAllocDuration)
fmt.Println("max_challenge_completion_time:", conf.MaxChallengeCompletionTime)
fmt.Println("min_offer_duration: ", conf.MinOfferDuration)
fmt.Println("min_blobber_capacity: ", conf.MinBlobberCapacity)
fmt.Println("max_delegates: ", conf.MaxDelegates)
fmt.Println("max_charge: ", conf.MaxCharge*100, "%")
fmt.Println("readpool:")
fmt.Println(" min_lock:", conf.ReadPool.MinLock, "tok")
fmt.Println(" min_lock_period:", conf.ReadPool.MinLockPeriod)
fmt.Println(" max_lock_period:", conf.ReadPool.MaxLockPeriod)
fmt.Println("writepool:")
fmt.Println(" min_lock:", conf.WritePool.MinLock, "tok")
fmt.Println(" min_lock_period:", conf.WritePool.MinLockPeriod)
fmt.Println(" max_lock_period:", conf.WritePool.MaxLockPeriod)
fmt.Println("stakepool:")
fmt.Println(" min_lock:", conf.StakePool.MinLock, "tok")
fmt.Println(" interest_rate:", conf.StakePool.InterestRate)
fmt.Println(" interest_interval:", conf.StakePool.InterestInterval)
fmt.Println("validator_reward: ", conf.ValidatorReward)
fmt.Println("blobber_slash: ", conf.BlobberSlash)
fmt.Println("max_read_price: ", conf.MaxReadPrice, "tok / GB")
fmt.Println("max_write_price: ", conf.MaxWritePrice, "tok / GB / time_unit")
fmt.Println("time_unit: ", conf.TimeUnit)
fmt.Println("failed_challenges_to_cancel: ", conf.FailedChallengesToCancel)
fmt.Println("failed_challenges_to_revoke_min_lock:", conf.FailedChallengesToRevokeMinLock)
fmt.Println("challenge_enabled: ", conf.ChallengeEnabled)
fmt.Println("max_challenges_per_generation: ", conf.MaxChallengesPerGeneration)
fmt.Println("challenge_rate_per_mb_min: ", conf.ChallengeGenerationRate)
}
// TODO: @Piers: update print logic sc-config; using datastructure might make sense instead of
// InputMap because some fields have specific type (like Balance) which includes formatting logic

// func printStorageSCConfig(conf *sdk.StorageSCConfig) {
// fmt.Println("min_alloc_size: ", conf.MinAllocSize)
// fmt.Println("min_alloc_duration: ", conf.MinAllocDuration)
// fmt.Println("max_challenge_completion_time:", conf.MaxChallengeCompletionTime)
// fmt.Println("min_offer_duration: ", conf.MinOfferDuration)
// fmt.Println("min_blobber_capacity: ", conf.MinBlobberCapacity)
// fmt.Println("max_delegates: ", conf.MaxDelegates)
// fmt.Println("max_charge: ", conf.MaxCharge*100, "%")
// fmt.Println("readpool:")
// fmt.Println(" min_lock:", conf.ReadPool.MinLock)
// fmt.Println(" min_lock_period:", conf.ReadPool.MinLockPeriod)
// fmt.Println(" max_lock_period:", conf.ReadPool.MaxLockPeriod)
// fmt.Println("writepool:")
// fmt.Println(" min_lock:", conf.WritePool.MinLock)
// fmt.Println(" min_lock_period:", conf.WritePool.MinLockPeriod)
// fmt.Println(" max_lock_period:", conf.WritePool.MaxLockPeriod)
// fmt.Println("stakepool:")
// fmt.Println(" min_lock:", conf.StakePool.MinLock)
// fmt.Println(" interest_rate:", conf.StakePool.InterestRate)
// fmt.Println(" interest_interval:", conf.StakePool.InterestInterval)
// fmt.Println("validator_reward: ", conf.ValidatorReward)
// fmt.Println("blobber_slash: ", conf.BlobberSlash)
// fmt.Println("max_read_price: ", conf.MaxReadPrice, "/ GB")
// fmt.Println("max_write_price: ", conf.MaxWritePrice, "/ GB / time_unit")
// fmt.Println("time_unit: ", conf.TimeUnit)
// fmt.Println("failed_challenges_to_cancel: ", conf.FailedChallengesToCancel)
// fmt.Println("failed_challenges_to_revoke_min_lock:", conf.FailedChallengesToRevokeMinLock)
// fmt.Println("challenge_enabled: ", conf.ChallengeEnabled)
// fmt.Println("max_challenges_per_generation: ", conf.MaxChallengesPerGeneration)
// fmt.Println("challenge_rate_per_mb_min: ", conf.ChallengeGenerationRate)
// }

// scConfig shows SC configurations
var scConfig = &cobra.Command{
Expand All @@ -60,7 +63,8 @@ var scConfig = &cobra.Command{
util.PrintJSON(conf)
return
}
printStorageSCConfig(conf)
util.PrintJSON(conf.Fields)
// printStorageSCConfig(conf)
},
}

Expand All @@ -76,8 +80,8 @@ func printBlobbers(nodes []*sdk.Blobber) {
val.Capacity.String())
fmt.Println(" last_health_check: ", val.LastHealthCheck)
fmt.Println(" terms:")
fmt.Println(" read_price: ", val.Terms.ReadPrice.String(), "tok / GB")
fmt.Println(" write_price: ", val.Terms.WritePrice.String(), "tok / GB / time_unit")
fmt.Println(" read_price: ", val.Terms.ReadPrice.String(), "/ GB")
fmt.Println(" write_price: ", val.Terms.WritePrice.String(), "/ GB / time_unit")
fmt.Println(" min_lock_demand: ", val.Terms.MinLockDemand)
fmt.Println(" cct: ", val.Terms.ChallengeCompletionTime.String())
fmt.Println(" max_offer_duration: ", val.Terms.MaxOfferDuration.String())
Expand Down Expand Up @@ -168,15 +172,15 @@ var blobberInfoCmd = &cobra.Command{
fmt.Println("last_health_check:", blob.LastHealthCheck.ToTime())
fmt.Println("capacity_used: ", blob.Used)
fmt.Println("terms:")
fmt.Println(" read_price: ", blob.Terms.ReadPrice, "tok / GB")
fmt.Println(" write_price: ", blob.Terms.WritePrice, "tok / GB")
fmt.Println(" read_price: ", blob.Terms.ReadPrice, "/ GB")
fmt.Println(" write_price: ", blob.Terms.WritePrice, "/ GB")
fmt.Println(" min_lock_demand: ", blob.Terms.MinLockDemand*100.0, "%")
fmt.Println(" max_offer_duration:", blob.Terms.MaxOfferDuration)
fmt.Println(" cct: ", blob.Terms.ChallengeCompletionTime)
fmt.Println("settings:")
fmt.Println(" delegate_wallet:", blob.StakePoolSettings.DelegateWallet)
fmt.Println(" min_stake: ", blob.StakePoolSettings.MinStake, "tok")
fmt.Println(" max_stake: ", blob.StakePoolSettings.MaxStake, "tok")
fmt.Println(" min_stake: ", blob.StakePoolSettings.MinStake)
fmt.Println(" max_stake: ", blob.StakePoolSettings.MaxStake)
fmt.Println(" num_delegates: ", blob.StakePoolSettings.NumDelegates)
fmt.Println(" service_charge: ", blob.StakePoolSettings.ServiceCharge*100, "%")
},
Expand Down

0 comments on commit de2f983

Please sign in to comment.