WIP: Begin ingestRelevantMessages - stores relevant messsages to disk
This commit is contained in:
parent
651783eb59
commit
4cc09baa97
|
@ -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")
|
||||
|
|
|
@ -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...)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue