more conversions.

This commit is contained in:
fiatjaf
2025-04-15 00:00:03 -03:00
parent f9e4a5efa3
commit 376834cbf9
117 changed files with 450 additions and 1019 deletions

View File

@@ -5,7 +5,7 @@ import (
"encoding/binary"
"encoding/hex"
"fiatjaf.com/nostrlib/nip77/negentropy"
"fiatjaf.com/nostr/nip77/negentropy"
)
type Accumulator struct {

View File

@@ -3,8 +3,8 @@ package empty
import (
"iter"
"github.com/nbd-wtf/go-nostr/nip77/negentropy"
"github.com/nbd-wtf/go-nostr/nip77/negentropy/storage"
"fiatjaf.com/nostr/nip77/negentropy"
"fiatjaf.com/nostr/nip77/negentropy/storage"
)
var acc storage.Accumulator

View File

@@ -1,7 +1,6 @@
package vector
import (
"encoding/hex"
"fmt"
"iter"
"slices"
@@ -24,7 +23,7 @@ func New() *Vector {
}
}
func (v *Vector) Insert(createdAt nostr.Timestamp, id string) {
func (v *Vector) Insert(createdAt nostr.Timestamp, id nostr.ID) {
if len(id) != 64 {
panic(fmt.Errorf("bad id size for added item: expected %d bytes, got %d", 32, len(id)/2))
}
@@ -68,10 +67,8 @@ func (v *Vector) FindLowerBound(begin, end int, bound negentropy.Bound) int {
func (v *Vector) Fingerprint(begin, end int) string {
v.acc.Reset()
tmp := make([]byte, 32)
for _, item := range v.Range(begin, end) {
hex.Decode(tmp, []byte(item.ID))
v.acc.AddBytes(tmp)
v.acc.AddBytes(item.ID[:])
}
return v.acc.GetFingerprint(end - begin)