Skip to content

Commit

Permalink
negentropy: fix one stupid bug and rename Initiate() to Start().
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Sep 19, 2024
1 parent 15aa7ac commit e9e96be
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nip77/negentropy/negentropy.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (n *Negentropy) String() string {
return fmt.Sprintf("<Negentropy %s with %d items>", label, n.storage.Size())
}

func (n *Negentropy) Initiate() string {
func (n *Negentropy) Start() string {
n.initialized = true
n.isClient = true

Expand Down
4 changes: 2 additions & 2 deletions nip77/negentropy/storage/vector/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ func New() *Vector {
}

func (v *Vector) Insert(createdAt nostr.Timestamp, id string) error {
if len(id)/2 != 32 {
return fmt.Errorf("bad id size for added item: expected %d, got %d", 32, len(id)/2)
if len(id) != 64 {
return fmt.Errorf("bad id size for added item: expected %d bytes, got %d", 32, len(id)/2)
}

item := negentropy.Item{Timestamp: createdAt, ID: id}
Expand Down
6 changes: 3 additions & 3 deletions nip77/negentropy/whatever_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ func runTestWith(t *testing.T,
n1 = negentropy.New(n1s, 1<<16)
for _, r := range n1Ranges {
for i := r[0]; i < r[1]; i++ {
n1s.Insert(events[i].CreatedAt, events[1].ID)
n1s.Insert(events[i].CreatedAt, events[i].ID)
}
}
n1s.Seal()

q = n1.Initiate()
q = n1.Start()
}

{
n2s := vector.New()
n2 = negentropy.New(n2s, 1<<16)
for _, r := range n2Ranges {
for i := r[0]; i < r[1]; i++ {
n2s.Insert(events[i].CreatedAt, events[1].ID)
n2s.Insert(events[i].CreatedAt, events[i].ID)
}
}
n2s.Seal()
Expand Down
2 changes: 1 addition & 1 deletion nip77/nip77.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func NegentropySync(ctx context.Context, store nostr.RelayStore, url string, fil
return err
}

msg := neg.Initiate()
msg := neg.Start()
open, _ := OpenEnvelope{id, filter, msg}.MarshalJSON()
err = <-r.Write(open)
if err != nil {
Expand Down

0 comments on commit e9e96be

Please sign in to comment.