Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions core/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ func (n *OpenBazaarNode) SendOfflineMessage(p peer.ID, k *libp2p.PubKey, m *pb.M
if aerr != nil {
return aerr
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mh, mherr := multihash.FromB58String(p.Pretty())
if mherr != nil {
return mherr
Expand All @@ -85,8 +83,18 @@ func (n *OpenBazaarNode) SendOfflineMessage(p peer.ID, k *libp2p.PubKey, m *pb.M
if err != nil {
return err
}
if m.MessageType != pb.Message_OFFLINE_ACK {
pointer.Purpose = ipfs.MESSAGE
pointer.CancelID = &p
err = n.Datastore.Pointers().Put(pointer)
if err != nil {
return err
}
}
OfflineMessageWaitGroup.Add(1)
go func() {
OfflineMessageWaitGroup.Add(1)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := ipfs.PublishPointer(n.IpfsNode, ctx, pointer)
if err != nil {
log.Error(err)
Expand All @@ -113,15 +121,6 @@ func (n *OpenBazaarNode) SendOfflineMessage(p peer.ID, k *libp2p.PubKey, m *pb.M
}
}
}

if m.MessageType != pb.Message_OFFLINE_ACK {
pointer.Purpose = ipfs.MESSAGE
pointer.CancelID = &p
err = n.Datastore.Pointers().Put(pointer)
if err != nil {
return err
}
}
return nil
}

Expand Down