now actually does something
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-03-27 19:57:58 -07:00
parent b3f672b84a
commit 2ecd833726
12 changed files with 213 additions and 91 deletions

View File

@@ -1,27 +1,30 @@
package toot
import "fmt"
import "encoding/json"
import "errors"
import "strings"
import "git.eeqj.de/sneak/feta/jsonapis"
import (
"encoding/json"
"errors"
"fmt"
"strings"
//import "github.com/davecgh/go-spew/spew"
import "github.com/rs/zerolog/log"
"git.eeqj.de/sneak/feta/jsonapis"
"github.com/rs/zerolog/log"
//import "encoding/hex"
import mh "github.com/multiformats/go-multihash"
import mhopts "github.com/multiformats/go-multihash/opts"
//import "github.com/davecgh/go-spew/spew"
//import "encoding/hex"
mh "github.com/multiformats/go-multihash"
mhopts "github.com/multiformats/go-multihash/opts"
)
// Hash is a type for storing a string-based base58 multihash of a
// toot's identity
type Hash string
// Toot is an object we use internally for storing a discovered toot
type Toot struct {
Original []byte
Parsed *jsonapis.APISerializedToot
Hash Hash
Hash string
FromHost string
}
@@ -111,7 +114,14 @@ func (t *Toot) identityHashInput() string {
)
}
func (t *Toot) GetHash() string {
if t.Hash == "" {
t.calcHash()
}
return t.Hash
}
func (t *Toot) calcHash() {
hi := t.identityHashInput()
t.Hash = Hash(t.multiHash([]byte(hi)))
t.Hash = string(t.multiHash([]byte(hi)))
}