Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Babbler optional #7

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions rpc/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io/ioutil"
"math/rand"
"net/http"
"os"
"strconv"

"github.com/pokt-network/pocket-core/app/cmd/rpc"
Expand Down Expand Up @@ -123,10 +124,24 @@ func NodeUnjailTransaction(config config.Config) {
sendRawTx(&msg, config, signer)
}

func generateRandomString() string {
if _, err := os.Stat("/usr/share/dict/words"); err == nil {
b := babble.NewBabbler()
return b.Babble()
}

var letters = []rune(
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
bytes := make([]rune, 10)
for i := range bytes {
bytes[i] = letters[rand.Intn(len(letters))]
}
return string(bytes)
}

func sendRawTx(msg types.ProtoMsg, config config.Config, signer crypto.PrivateKey) {
fmt.Println(msg)
b := babble.NewBabbler()
txBz, err := newTxBz(memCodec(), msg, config.ChainID, signer, Fee, b.Babble(), getLegacyCodec(config))
txBz, err := newTxBz(memCodec(), msg, config.ChainID, signer, Fee, generateRandomString(), getLegacyCodec(config))
if err != nil {
fmt.Println(err)
return
Expand Down Expand Up @@ -307,8 +322,7 @@ func getRandomAmount() types.BigInt {
func getRandomDomain() string {
prefix := "https://"
suffix := ".com:8081"
babbler := babble.NewBabbler()
return prefix + babbler.Babble() + suffix
return prefix + generateRandomString() + suffix
}

func newTxBz(cdc *codec.Codec, msg types.ProtoMsg, chainID string, pk crypto.PrivateKey, fee int64, memo string, legacyCodec bool) (transactionBz []byte, err error) {
Expand Down