Skip to content

Commit

Permalink
Add output for threadcount and key generation time to cmd/genkey
Browse files Browse the repository at this point in the history
This change is to display information about the key generation process.

Specifically, two bits of information are now displayed
 * The number of threads created to search for keys, and
 * The time taken to generate a successful "next best" key
  • Loading branch information
jjolly authored and neilalexander committed Oct 21, 2023
1 parent a2dffef commit 8ea20cd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/genkeys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"fmt"
"net"
"runtime"
"time"

"github.com/yggdrasil-network/yggdrasil-go/src/address"
)
Expand All @@ -27,6 +28,8 @@ type keySet struct {

func main() {
threads := runtime.GOMAXPROCS(0)
fmt.Println("Threads:", threads)
start := time.Now()
var currentBest ed25519.PublicKey
newKeys := make(chan keySet, threads)
for i := 0; i < threads; i++ {
Expand All @@ -36,7 +39,7 @@ func main() {
newKey := <-newKeys
if isBetter(currentBest, newKey.pub) || len(currentBest) == 0 {
currentBest = newKey.pub
fmt.Println("-----")
fmt.Println("-----", time.Since(start))
fmt.Println("Priv:", hex.EncodeToString(newKey.priv))
fmt.Println("Pub:", hex.EncodeToString(newKey.pub))
addr := address.AddrForKey(newKey.pub)
Expand Down

0 comments on commit 8ea20cd

Please sign in to comment.