1. moved address to core

This commit is contained in:
vadym 2022-10-30 21:58:42 +02:00
parent b5f79eadcb
commit 6319d6231b
15 changed files with 61 additions and 60 deletions

View file

@ -19,7 +19,7 @@ import (
"net"
"runtime"
"github.com/RiV-chain/RiV-mesh/src/address"
"github.com/RiV-chain/RiV-mesh/src/core"
)
type keySet struct {
@ -41,7 +41,7 @@ func main() {
fmt.Println("-----")
fmt.Println("Priv:", hex.EncodeToString(newKey.priv))
fmt.Println("Pub:", hex.EncodeToString(newKey.pub))
addr := address.AddrForKey(newKey.pub)
addr := core.AddrForKey(newKey.pub)
fmt.Println("IP:", net.IP(addr[:]).String())
}
}

View file

@ -25,7 +25,7 @@ import (
"github.com/kardianos/minwinsvc"
"github.com/mitchellh/mapstructure"
"github.com/RiV-chain/RiV-mesh/src/address"
//"github.com/RiV-chain/RiV-mesh/src/address"
"github.com/RiV-chain/RiV-mesh/src/admin"
"github.com/RiV-chain/RiV-mesh/src/config"
"github.com/RiV-chain/RiV-mesh/src/defaults"
@ -261,6 +261,7 @@ func run(args yggArgs, ctx context.Context) {
if cfg == nil {
return
}
n := &node{}
// Have we been asked for the node address yet? If so, print it and then stop.
getNodeKey := func() ed25519.PublicKey {
if pubkey, err := hex.DecodeString(cfg.PrivateKey); err == nil {
@ -271,14 +272,14 @@ func run(args yggArgs, ctx context.Context) {
switch {
case args.getaddr:
if key := getNodeKey(); key != nil {
addr := address.AddrForKey(key)
addr := n.core.AddrForKey(key)
ip := net.IP(addr[:])
fmt.Println(ip.String())
}
return
case args.getsnet:
if key := getNodeKey(); key != nil {
snet := address.SubnetForKey(key)
snet := n.core.SubnetForKey(key)
ipnet := net.IPNet{
IP: append(snet[:], 0, 0, 0, 0, 0, 0, 0, 0),
Mask: net.CIDRMask(len(snet)*8, 128),
@ -291,7 +292,6 @@ func run(args yggArgs, ctx context.Context) {
cfg.HttpAddress = args.httpaddress
cfg.WwwRoot = args.wwwroot
n := &node{}
// Setup the RiV-mesh node itself.
{
sk, err := hex.DecodeString(cfg.PrivateKey)