Skip to content

Commit

Permalink
Allow changing thread count
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkinj1 committed Jan 3, 2020
1 parent e298fa3 commit ada012e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ Generate 5 addresses (the default is 1)
./cosmosvanity -n 5
```

Restrict to using only 1 CPU thread. This value defaults to the number of CPUs available.
```bash
./cosmosvanity --cpus 1
```

Combine flags introduced above
```bash
./cosmosvanity --contains 8888 --startswith a --endswith c
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func countUnionChars(s string, letterSet string) int {

func main() {
var walletsToFind *int = flag.IntP("count", "n", 1, "Amount of matching wallets to find")
var cpuCount *int = flag.Int("cpus", runtime.NumCPU(), "Amount of CPU cores to use")

var mustContain *string = flag.StringP("contains", "c", "", "A string that the address must contain")
var mustStartWith *string = flag.StringP("startswith", "s", "", "A string that the address must start with")
Expand All @@ -140,6 +141,10 @@ func main() {
fmt.Println("ERROR: The number of wallets to generate must be 1 or more")
os.Exit(1)
}
if *cpuCount < 1 {
fmt.Println("ERROR: Must use at least 1 CPU core")
os.Exit(1)
}

m := matcher{
StartsWith: strings.ToLower(*mustStartWith),
Expand All @@ -158,7 +163,7 @@ func main() {

var matchingWallet wallet
for i := 0; i < *walletsToFind; i++ {
matchingWallet = findMatchingWalletConcurrent(m, runtime.NumCPU())
matchingWallet = findMatchingWalletConcurrent(m, *cpuCount)
fmt.Printf(":::: Matching wallet %d/%d found ::::\n", i+1, *walletsToFind)
fmt.Println(matchingWallet)
}
Expand Down

0 comments on commit ada012e

Please sign in to comment.