whisper: big refactoring (#13852)
* whisper: GetMessages fixed; size restriction updated * whisper: made PoW and MaxMsgSize customizable * whisper: test added * whisper: sym key management changed * whisper: identity management refactored * whisper: API refactoring (Post and Filter) * whisper: big refactoring complete * whisper: spelling fix * whisper: variable topic size allowed for a filter * whisper: final update * whisper: formatting * whisper: file exchange introduced in wnode * whisper: bugfix * whisper: API updated + new tests * whisper: statistics updated * whisper: wnode server updated * whisper: allowed filtering for variable topic size * whisper: tests added * whisper: resolving merge conflicts * whisper: refactoring (documenting mostly) * whsiper: tests fixed * whisper: down cased error messages * whisper: documenting the API functions * whisper: logging fixed * whisper: fixed wnode parameters * whisper: logs fixed (typos)
This commit is contained in:
@@ -55,13 +55,13 @@ func newPeer(host *Whisper, remote *p2p.Peer, rw p2p.MsgReadWriter) *Peer {
|
||||
// into the network.
|
||||
func (p *Peer) start() {
|
||||
go p.update()
|
||||
log.Debug(fmt.Sprintf("%v: whisper started", p.peer))
|
||||
log.Trace("start", "peer", p.ID())
|
||||
}
|
||||
|
||||
// stop terminates the peer updater, stopping message forwarding to it.
|
||||
func (p *Peer) stop() {
|
||||
close(p.quit)
|
||||
log.Debug(fmt.Sprintf("%v: whisper stopped", p.peer))
|
||||
log.Trace("stop", "peer", p.ID())
|
||||
}
|
||||
|
||||
// handshake sends the protocol initiation status message to the remote peer and
|
||||
@@ -78,19 +78,19 @@ func (p *Peer) handshake() error {
|
||||
return err
|
||||
}
|
||||
if packet.Code != statusCode {
|
||||
return fmt.Errorf("peer sent %x before status packet", packet.Code)
|
||||
return fmt.Errorf("peer [%x] sent packet %x before status packet", p.ID(), packet.Code)
|
||||
}
|
||||
s := rlp.NewStream(packet.Payload, uint64(packet.Size))
|
||||
peerVersion, err := s.Uint()
|
||||
if err != nil {
|
||||
return fmt.Errorf("bad status message: %v", err)
|
||||
return fmt.Errorf("peer [%x] sent bad status message: %v", p.ID(), err)
|
||||
}
|
||||
if peerVersion != ProtocolVersion {
|
||||
return fmt.Errorf("protocol version mismatch %d != %d", peerVersion, ProtocolVersion)
|
||||
return fmt.Errorf("peer [%x]: protocol version mismatch %d != %d", p.ID(), peerVersion, ProtocolVersion)
|
||||
}
|
||||
// Wait until out own status is consumed too
|
||||
if err := <-errc; err != nil {
|
||||
return fmt.Errorf("failed to send status packet: %v", err)
|
||||
return fmt.Errorf("peer [%x] failed to send status packet: %v", p.ID(), err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func (p *Peer) update() {
|
||||
|
||||
case <-transmit.C:
|
||||
if err := p.broadcast(); err != nil {
|
||||
log.Info(fmt.Sprintf("%v: broadcast failed: %v", p.peer, err))
|
||||
log.Trace("broadcast failed", "reason", err, "peer", p.ID())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func (p *Peer) broadcast() error {
|
||||
if err := p2p.Send(p.ws, messagesCode, transmit); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Trace(fmt.Sprint(p.peer, "broadcasted", len(transmit), "message(s)"))
|
||||
log.Trace("broadcast", "num. messages", len(transmit))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user