-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from D4ryl00/fix/events
fix: directChannel not working
- Loading branch information
Showing
7 changed files
with
204 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package baseorbitdb | ||
|
||
import ( | ||
"berty.tech/go-orbit-db/iface" | ||
"github.com/libp2p/go-libp2p/core/peer" | ||
) | ||
|
||
type EventExchangeHeads struct { | ||
Peer peer.ID | ||
Message *iface.MessageExchangeHeads | ||
} | ||
|
||
func NewEventExchangeHeads(p peer.ID, msg *iface.MessageExchangeHeads) EventExchangeHeads { | ||
return EventExchangeHeads{ | ||
Peer: p, | ||
Message: msg, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package baseorbitdb | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
ipfslog "berty.tech/go-ipfs-log" | ||
"berty.tech/go-orbit-db/iface" | ||
) | ||
|
||
func (o *orbitDB) handleEventExchangeHeads(ctx context.Context, e *iface.MessageExchangeHeads, store iface.Store) error { | ||
untypedHeads := make([]ipfslog.Entry, len(e.Heads)) | ||
for i, h := range e.Heads { | ||
untypedHeads[i] = h | ||
} | ||
|
||
o.logger.Debug(fmt.Sprintf("%s: Received %d heads for '%s':", o.PeerID().String(), len(untypedHeads), e.Address)) | ||
|
||
if len(untypedHeads) > 0 { | ||
if err := store.Sync(ctx, untypedHeads); err != nil { | ||
return fmt.Errorf("unable to sync heads: %w", err) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.