mirror of
https://github.com/status-im/whisper.git
synced 2025-02-08 00:45:48 +00:00
Use rawsyncresponse
This commit is contained in:
parent
f55e777bd6
commit
f62a6add56
@ -142,6 +142,15 @@ type SyncResponse struct {
|
|||||||
Error string
|
Error string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RawSyncResponse is a struct representing a response sent to the peer
|
||||||
|
// asking for syncing archived envelopes.
|
||||||
|
type RawSyncResponse struct {
|
||||||
|
Envelopes []rlp.RawValue
|
||||||
|
Cursor []byte
|
||||||
|
Final bool // if true it means all envelopes were processed
|
||||||
|
Error string
|
||||||
|
}
|
||||||
|
|
||||||
// MessagesResponse sent as a response after processing batch of envelopes.
|
// MessagesResponse sent as a response after processing batch of envelopes.
|
||||||
type MessagesResponse struct {
|
type MessagesResponse struct {
|
||||||
// Hash is a hash of all envelopes sent in the single batch.
|
// Hash is a hash of all envelopes sent in the single batch.
|
||||||
|
@ -493,6 +493,11 @@ func (whisper *Whisper) SendSyncResponse(p *Peer, data SyncResponse) error {
|
|||||||
return p2p.Send(p.ws, p2pSyncResponseCode, data)
|
return p2p.Send(p.ws, p2pSyncResponseCode, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SendRawSyncResponse sends a response to a Mail Server with a slice of envelopes.
|
||||||
|
func (whisper *Whisper) SendRawSyncResponse(p *Peer, data RawSyncResponse) error {
|
||||||
|
return p2p.Send(p.ws, p2pSyncResponseCode, data)
|
||||||
|
}
|
||||||
|
|
||||||
// SendP2PMessage sends a peer-to-peer message to a specific peer.
|
// SendP2PMessage sends a peer-to-peer message to a specific peer.
|
||||||
func (whisper *Whisper) SendP2PMessage(peerID []byte, envelopes ...*Envelope) error {
|
func (whisper *Whisper) SendP2PMessage(peerID []byte, envelopes ...*Envelope) error {
|
||||||
p, err := whisper.getPeer(peerID)
|
p, err := whisper.getPeer(peerID)
|
||||||
@ -1073,12 +1078,7 @@ func (whisper *Whisper) runMessageLoop(p *Peer, rw p2p.MsgReadWriter) error {
|
|||||||
|
|
||||||
log.Info("received sync response", "count", len(resp.Envelopes), "final", resp.Final, "err", resp.Error, "cursor", resp.Cursor)
|
log.Info("received sync response", "count", len(resp.Envelopes), "final", resp.Final, "err", resp.Error, "cursor", resp.Cursor)
|
||||||
|
|
||||||
for _, rawEnvelope := range resp.Envelopes {
|
for _, envelope := range resp.Envelopes {
|
||||||
var envelope *Envelope
|
|
||||||
if err := rlp.DecodeBytes(rawEnvelope, &envelope); err != nil {
|
|
||||||
return errors.New("invalid envelopes")
|
|
||||||
}
|
|
||||||
|
|
||||||
whisper.mailServer.Archive(envelope)
|
whisper.mailServer.Archive(envelope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user