Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Commit

Permalink
Make vendoring tunable with build tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tdemin committed Aug 8, 2020
1 parent e6c3e38 commit 5c1dd7a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -7,6 +7,10 @@ code for generating keys and utilizing multiple CPU threads for mining.

`% go get -u -v git.tdem.in/tdemin/syg_go`

This program contains some modded code from Yggdrasil that aims to improve
performance. If you prefer to use original Yggdrasil code, set `-tags original`
flag in the command above.

### History

SimpleYggGen is originally a project by [@acetone](https://notabug.org/acetone),
Expand Down
5 changes: 5 additions & 0 deletions crypto.go
Expand Up @@ -5,6 +5,11 @@ import (
"github.com/yggdrasil-network/yggdrasil-go/src/crypto"
)

// custom function selectors, see crypto_xxx.go
var (
addrForNodeID func(*crypto.NodeID) *address.Address
)

// AddrForNodeID is a variant of Yggdrasil's src/address.AddrForNodeID that
// might be slightly optimized for performance.
//
Expand Down
14 changes: 14 additions & 0 deletions crypto_original.go
@@ -0,0 +1,14 @@
// +build original

package main

import (
"log"

"github.com/yggdrasil-network/yggdrasil-go/src/address"
)

func init() {
log.Println("using unmodified Yggdrasil code")
addrForNodeID = address.AddrForNodeID
}
10 changes: 10 additions & 0 deletions crypto_vendor.go
@@ -0,0 +1,10 @@
// +build !original

package main

import "log"

func init() {
log.Println("using vendored syg_go code")
addrForNodeID = AddrForNodeID
}
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -73,7 +73,7 @@ func doBoxKeys(out chan<- keySet) {
for {
pub, priv := crypto.NewBoxKeys()
id := crypto.GetNodeID(pub)
ip := net.IP(AddrForNodeID(id)[:]).String()
ip := net.IP(addrForNodeID(id)[:]).String()
out <- keySet{priv[:], pub[:], id[:], ip}
}
}

0 comments on commit 5c1dd7a

Please sign in to comment.