From c7ea223a9a1b045ab00572a6407243f01a6a91b3 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sun, 14 May 2023 10:16:33 +0100 Subject: [PATCH] Update mobile bindings --- contrib/mobile/mobile.go | 19 +++++++++++++------ contrib/mobile/mobile_test.go | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/contrib/mobile/mobile.go b/contrib/mobile/mobile.go index 7993799..dcf5eb2 100644 --- a/contrib/mobile/mobile.go +++ b/contrib/mobile/mobile.go @@ -190,10 +190,9 @@ func (m *Yggdrasil) GetPublicKeyString() string { return hex.EncodeToString(m.core.GetSelf().Key) } -// GetCoordsString gets the node's coordinates -func (m *Yggdrasil) GetCoordsString() string { - return "N/A" - // return fmt.Sprintf("%v", m.core.GetSelf().Coords) +// GetRoutingEntries gets the number of entries in the routing table +func (m *Yggdrasil) GetRoutingEntries() int { + return int(m.core.GetSelf().RoutingEntries) } func (m *Yggdrasil) GetPeersJSON() (result string) { @@ -219,8 +218,16 @@ func (m *Yggdrasil) GetPeersJSON() (result string) { } } -func (m *Yggdrasil) GetDHTJSON() (result string) { - if res, err := json.Marshal(m.core.GetDHT()); err == nil { +func (m *Yggdrasil) GetPathsJSON() (result string) { + if res, err := json.Marshal(m.core.GetPaths()); err == nil { + return string(res) + } else { + return "{}" + } +} + +func (m *Yggdrasil) GetTreeJSON() (result string) { + if res, err := json.Marshal(m.core.GetTree()); err == nil { return string(res) } else { return "{}" diff --git a/contrib/mobile/mobile_test.go b/contrib/mobile/mobile_test.go index 1991640..880e5fc 100644 --- a/contrib/mobile/mobile_test.go +++ b/contrib/mobile/mobile_test.go @@ -9,7 +9,7 @@ func TestStartYggdrasil(t *testing.T) { } t.Log("Address:", ygg.GetAddressString()) t.Log("Subnet:", ygg.GetSubnetString()) - t.Log("Coords:", ygg.GetCoordsString()) + t.Log("Routing entries:", ygg.GetRoutingEntries()) if err := ygg.Stop(); err != nil { t.Fatalf("Failed to stop Yggdrasil: %s", err) }