Skip to content

Commit

Permalink
Merge pull request #7 from planetary-social/replicate-my-feed
Browse files Browse the repository at this point in the history
Ask to replicate our own feed when using EBT
  • Loading branch information
rabble authored Oct 24, 2022
2 parents c7dc092 + 471bad0 commit a76247b
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions plugins/ebt/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,14 @@ func (h *MUXRPCHandler) HandleCall(ctx context.Context, req *muxrpc.Request) {
h.Loop(ctx, snk, src, req.RemoteAddr())
}

func (h *MUXRPCHandler) sendState(ctx context.Context, tx *muxrpc.ByteSink, remote refs.FeedRef) error {
func (h *MUXRPCHandler) sendState(tx *muxrpc.ByteSink, remote refs.FeedRef) error {
currState, err := h.stateMatrix.Changed(h.self, remote)
if err != nil {
return fmt.Errorf("failed to get changed frontier: %w", err)
}

selfRef := h.self.String()

// don't receive your own feed
if myNote, has := currState[selfRef]; has {
myNote.Receive = false
currState[selfRef] = myNote
}

for k, note := range currState {
fmt.Println("sending state", k, note.Seq, note.Receive, note.Replicate)
level.Debug(h.info).Log("event", "ebt sending note", "feed", k, "seq", note.Seq, "receive", note.Receive, "replicate", note.Replicate)
}

tx.SetEncoding(muxrpc.TypeJSON)
Expand Down Expand Up @@ -155,7 +147,7 @@ func (h *MUXRPCHandler) Loop(ctx context.Context, tx *muxrpc.ByteSink, rx *muxrp
}
}()

if err := h.sendState(ctx, tx, peer); err != nil {
if err := h.sendState(tx, peer); err != nil {
h.check(err)
return
}
Expand Down

0 comments on commit a76247b

Please sign in to comment.