mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-06 13:09:16 +02:00
negentropy: fix one stupid bug and rename Initiate() to Start().
This commit is contained in:
parent
15aa7ac31e
commit
e9e96be95e
@ -56,7 +56,7 @@ func (n *Negentropy) String() string {
|
|||||||
return fmt.Sprintf("<Negentropy %s with %d items>", label, n.storage.Size())
|
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.initialized = true
|
||||||
n.isClient = true
|
n.isClient = true
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ func New() *Vector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *Vector) Insert(createdAt nostr.Timestamp, id string) error {
|
func (v *Vector) Insert(createdAt nostr.Timestamp, id string) error {
|
||||||
if len(id)/2 != 32 {
|
if len(id) != 64 {
|
||||||
return fmt.Errorf("bad id size for added item: expected %d, got %d", 32, len(id)/2)
|
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}
|
item := negentropy.Item{Timestamp: createdAt, ID: id}
|
||||||
|
@ -79,12 +79,12 @@ func runTestWith(t *testing.T,
|
|||||||
n1 = negentropy.New(n1s, 1<<16)
|
n1 = negentropy.New(n1s, 1<<16)
|
||||||
for _, r := range n1Ranges {
|
for _, r := range n1Ranges {
|
||||||
for i := r[0]; i < r[1]; i++ {
|
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()
|
n1s.Seal()
|
||||||
|
|
||||||
q = n1.Initiate()
|
q = n1.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -92,7 +92,7 @@ func runTestWith(t *testing.T,
|
|||||||
n2 = negentropy.New(n2s, 1<<16)
|
n2 = negentropy.New(n2s, 1<<16)
|
||||||
for _, r := range n2Ranges {
|
for _, r := range n2Ranges {
|
||||||
for i := r[0]; i < r[1]; i++ {
|
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()
|
n2s.Seal()
|
||||||
|
@ -59,7 +59,7 @@ func NegentropySync(ctx context.Context, store nostr.RelayStore, url string, fil
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := neg.Initiate()
|
msg := neg.Start()
|
||||||
open, _ := OpenEnvelope{id, filter, msg}.MarshalJSON()
|
open, _ := OpenEnvelope{id, filter, msg}.MarshalJSON()
|
||||||
err = <-r.Write(open)
|
err = <-r.Write(open)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user