Implemented ID and PubKey

pull/37/head
マリウス 2 years ago
parent 51a79a3dce
commit 6f22c3cacf
No known key found for this signature in database
GPG Key ID: 272ED814BF63261F

@ -14,6 +14,7 @@ import (
config "github.com/ipfs/go-ipfs-config" config "github.com/ipfs/go-ipfs-config"
"github.com/ipfs/go-ipfs/core" "github.com/ipfs/go-ipfs/core"
icore "github.com/ipfs/interface-go-ipfs-core" icore "github.com/ipfs/interface-go-ipfs-core"
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"go.uber.org/zap" "go.uber.org/zap"
@ -82,6 +83,19 @@ func (db *Database) init() (error) {
return nil return nil
} }
func(db *Database) GetOwnID() string {
return db.OrbitDB.Identity().ID
}
func(db *Database) GetOwnPubKey() crypto.PubKey {
pubKey, err := db.OrbitDB.Identity().GetPublicKey()
if err != nil {
return nil
}
return pubKey
}
func(db *Database) connectToPeers() error { func(db *Database) connectToPeers() error {
var wg sync.WaitGroup var wg sync.WaitGroup

@ -93,9 +93,13 @@ func main() {
} }
err = db.Connect(func(address string) { err = db.Connect(func(address string) {
TUI.Meta["myID"] = db.GetOwnID()
TUI.Meta["myPubKey"] = db.GetOwnPubKey()
TUI.Views["mainscreen"].(*tui.Mainscreen).SetFooter(address) TUI.Views["mainscreen"].(*tui.Mainscreen).SetFooter(address)
articles, articlesRoots, _ = db.ListArticles() articles, articlesRoots, _ = db.ListArticles()
time.Sleep(time.Second * 2) time.Sleep(time.Second * 2)
TUI.SetView("mainscreen", true) TUI.SetView("mainscreen", true)

@ -40,6 +40,8 @@ type TUI struct {
Version string Version string
VersionLatest string VersionLatest string
Meta map[string]interface{}
// The fun starts here // The fun starts here
Player *common.Player Player *common.Player
} }
@ -82,6 +84,8 @@ func Init(embedfs *embed.FS, cfg *config.Config, cch *cache.Cache, logger *zap.L
t.Stats = make(map[string]int64) t.Stats = make(map[string]int64)
t.Meta = make(map[string]interface{})
logoBytes, err := embedfs.ReadFile("superhighway84.jpeg") logoBytes, err := embedfs.ReadFile("superhighway84.jpeg")
if err != nil { if err != nil {
log.Panicln(err) log.Panicln(err)

Loading…
Cancel
Save