Remove Statistical Package (#3129)

This commit is contained in:
Nishant Das 2019-08-03 19:17:46 +05:30 committed by terence tsao
parent 0beb919fc0
commit b1fcaa03ae
3 changed files with 0 additions and 44 deletions

View File

@ -977,12 +977,6 @@ go_repository(
importpath = "gopkg.in/natefinch/npipe.v2", importpath = "gopkg.in/natefinch/npipe.v2",
) )
go_repository(
name = "org_gonum_v1_gonum",
commit = "70a1e933af10e87000d2ccabdd509b87d8626153",
importpath = "gonum.org/v1/gonum",
)
go_repository( go_repository(
name = "org_golang_x_exp", name = "org_golang_x_exp",
commit = "438050ddec5e7f808979ed57d041cebbc8e2d8a9", commit = "438050ddec5e7f808979ed57d041cebbc8e2d8a9",

View File

@ -19,8 +19,6 @@ go_library(
"@com_github_sirupsen_logrus//:go_default_library", "@com_github_sirupsen_logrus//:go_default_library",
"@com_github_urfave_cli//:go_default_library", "@com_github_urfave_cli//:go_default_library",
"@com_github_x_cray_logrus_prefixed_formatter//:go_default_library", "@com_github_x_cray_logrus_prefixed_formatter//:go_default_library",
"@org_golang_x_exp//rand:go_default_library",
"@org_gonum_v1_gonum//stat/distuv:go_default_library",
], ],
) )

View File

@ -6,7 +6,6 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math"
"math/big" "math/big"
"os" "os"
"time" "time"
@ -24,8 +23,6 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/urfave/cli" "github.com/urfave/cli"
prefixed "github.com/x-cray/logrus-prefixed-formatter" prefixed "github.com/x-cray/logrus-prefixed-formatter"
rand2 "golang.org/x/exp/rand"
"gonum.org/v1/gonum/stat/distuv"
) )
var ( var (
@ -43,8 +40,6 @@ func main() {
var numberOfDeposits int64 var numberOfDeposits int64
var depositAmount int64 var depositAmount int64
var depositDelay int64 var depositDelay int64
var variableTx bool
var txDeviation int64
var randomKey bool var randomKey bool
customFormatter := new(prefixed.TextFormatter) customFormatter := new(prefixed.TextFormatter)
@ -112,17 +107,6 @@ func main() {
Usage: "The time delay between sending the deposits to the contract(in seconds)", Usage: "The time delay between sending the deposits to the contract(in seconds)",
Destination: &depositDelay, Destination: &depositDelay,
}, },
cli.BoolFlag{
Name: "variableTx",
Usage: "This enables variable transaction latencies to simulate real-world transactions",
Destination: &variableTx,
},
cli.Int64Flag{
Name: "txDeviation",
Usage: "The standard deviation between transaction times",
Value: 2,
Destination: &txDeviation,
},
cli.BoolFlag{ cli.BoolFlag{
Name: "random-key", Name: "random-key",
Usage: "Use a randomly generated keystore key", Usage: "Use a randomly generated keystore key",
@ -183,8 +167,6 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
statDist := buildStatisticalDist(depositDelay, numberOfDeposits, txDeviation)
validatorKeys := make(map[string]*prysmKeyStore.Key) validatorKeys := make(map[string]*prysmKeyStore.Key)
if randomKey { if randomKey {
validatorKey, err := prysmKeyStore.NewKey(rand.Reader) validatorKey, err := prysmKeyStore.NewKey(rand.Reader)
@ -221,12 +203,6 @@ func main() {
"Transaction Hash": fmt.Sprintf("%#x", tx.Hash()), "Transaction Hash": fmt.Sprintf("%#x", tx.Hash()),
}).Infof("Deposit %d sent to contract address %v for validator with a public key %#x", i, depositContractAddr, validatorKey.PublicKey.Marshal()) }).Infof("Deposit %d sent to contract address %v for validator with a public key %#x", i, depositContractAddr, validatorKey.PublicKey.Marshal())
// If flag is enabled make transaction times variable
if variableTx {
time.Sleep(time.Duration(math.Abs(statDist.Rand())) * time.Second)
continue
}
time.Sleep(time.Duration(depositDelay) * time.Second) time.Sleep(time.Duration(depositDelay) * time.Second)
} }
} }
@ -238,18 +214,6 @@ func main() {
} }
} }
func buildStatisticalDist(depositDelay int64, numberOfDeposits int64, txDeviation int64) *distuv.StudentsT {
src := rand2.NewSource(uint64(time.Now().Unix()))
dist := &distuv.StudentsT{
Mu: float64(depositDelay),
Sigma: float64(txDeviation),
Nu: float64(numberOfDeposits - 1),
Src: src,
}
return dist
}
func loadTextFromFile(filepath string) string { func loadTextFromFile(filepath string) string {
// #nosec - Inclusion of file via variable is OK for this tool. // #nosec - Inclusion of file via variable is OK for this tool.
file, err := os.Open(filepath) file, err := os.Open(filepath)