WIP: Begin ingestRelevantMessages - stores relevant messsages to disk

This commit is contained in:
Netscape Navigator 2020-10-21 07:35:04 -05:00
parent 651783eb59
commit 4cc09baa97
2 changed files with 26 additions and 1 deletions

View File

@ -1,9 +1,28 @@
package main
import "errors"
import (
"errors"
"fmt"
"io/ioutil"
)
/** ingestRelevantMessages takes an array of Pigeon messages
and adds them to the local database, assuming that they are
messages of interest. */
func ingestRelevantMessages(msgs []pigeonMessage) {
for _, message := range msgs {
fmt.Printf("Peer %s has %s status\n", message.author[0:13], getPeerStatus(message.author))
}
panic("This is where I stopped")
}
func importBundle(path string) error {
// Get messages.pgn file
dat, err1 := ioutil.ReadFile(path)
check(err1, "Problem opening %s. Error: %s", path, err1)
msgs, err2 := parseMessage(string(dat))
check(err2, "Failed to parse %s. Error: %s", path, err2)
ingestRelevantMessages(msgs)
// Parse messages
// Map over messages
return errors.New("Not done yet")

View File

@ -41,3 +41,9 @@ func CreateIdentity() (ed25519.PublicKey, ed25519.PrivateKey) {
func panicf(tpl string, args ...interface{}) {
panic(fmt.Sprintf(tpl, args...))
}
func check(e error, tpl string, args ...interface{}) {
if e != nil {
panicf(tpl, args...)
}
}