Skip to content

Commit 7ad7c95

Browse files
cleanup
1 parent 9299b34 commit 7ad7c95

5 files changed

Lines changed: 9 additions & 19 deletions

File tree

controller/block.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ func (c *Controller) HandlePeerBlock(msg *lib.BlockMessage, syncing bool) (*lib.
394394
}
395395
}
396396
} else {
397-
// TODO improve logging for LoadCommittee
398397
// load the committee from the root chain using the root height embedded in the certificate message
399398
v, err := c.Consensus.LoadCommittee(c.LoadRootChainId(qc.Header.Height), qc.Header.RootHeight)
400399
if err != nil {

p2p/conn.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const (
2626
dataFlowRatePerS = 500 * units.KB // the maximum number of bytes that may be sent or received per second per MultiConn
2727
maxMessageSize = 10 * units.Megabyte // the maximum total size of a message once all the packets are added up
2828
maxChanSize = 1 // maximum number of items in a channel before blocking
29-
maxInboxQueueSize = 15 // maxinum number of items in inbox queue before blocking
30-
maxStreamSendQueueSize = 15 // maximum number of items in a stream send queue before blocking
29+
maxInboxQueueSize = 100 // maximum number of items in inbox queue before blocking
30+
maxStreamSendQueueSize = 100 // maximum number of items in a stream send queue before blocking
3131

3232
// "Peer Reputation Points" are actively maintained for each peer the node is connected to
3333
// These points allow a node to track peer behavior over its lifetime, allowing it to disconnect from faulty peers
@@ -50,9 +50,7 @@ const (
5050
UnknownMessageSlash = -3 // unknown message type is received
5151
BadStreamSlash = -3 // unknown stream id is received
5252
InvalidTxRep = -3 // rep slash for sending us an invalid transaction
53-
NotValRep = -3 // rep slash for sending us a validator only message but not being a validator
5453
InvalidBlockRep = -3 // rep slash for sending an invalid block (certificate) message
55-
InvalidJustifyRep = -3 // rep slash for sending an invalid certificate justification
5654
BlockReqExceededRep = -3 // rep slash for over-requesting blocks (certificates)
5755
MaxMessageExceededSlash = -10 // slash for sending a 'Message (sum of Packets)' above the allowed maximum size
5856
)
@@ -154,7 +152,7 @@ func (c *MultiConn) startSendService() {
154152
}
155153
}()
156154
m := limiter.New(0, 0)
157-
ping, err := time.NewTicker(pingInterval), lib.ErrorI(nil)
155+
ping := time.NewTicker(pingInterval)
158156
pongTimer := time.NewTimer(pongTimeoutDuration)
159157
var packet *Packet
160158
defer func() { lib.StopTimer(pongTimer); ping.Stop(); m.Done() }()
@@ -174,11 +172,8 @@ func (c *MultiConn) startSendService() {
174172
case packet = <-c.streams[lib.Topic_PEERS_REQUEST].sendQueue:
175173
c.sendPacket(packet, m)
176174
case <-ping.C: // fires every 'pingInterval'
177-
//c.log.Debugf("Send Ping to: %s", lib.BytesToTruncatedString(c.Address.PublicKey))
178175
// send a ping to the peer
179-
if err = c.sendWireBytes(new(Ping), m); err != nil {
180-
break
181-
}
176+
c.sendWireBytes(new(Ping), m)
182177
// reset the pong timer
183178
lib.StopTimer(pongTimer)
184179
// set the pong timer to execute an Error function if the timer expires before receiving a pong
@@ -195,8 +190,6 @@ func (c *MultiConn) startSendService() {
195190
// exit
196191
return
197192
}
198-
// log the pong sending
199-
//c.log.Debugf("Send Pong to: %s", lib.BytesToTruncatedString(c.Address.PublicKey))
200193
// send a pong
201194
c.sendWireBytes(new(Pong), m)
202195
case _, open := <-c.receivedPong: // fires when receive service got a 'pong' message
@@ -257,10 +250,9 @@ func (c *MultiConn) startReceiveService() {
257250
return
258251
}
259252
case *Ping: // receive ping message notifies the "send" service to respond with a 'pong' message
260-
//c.log.Debugf("Received ping from %s", lib.BytesToTruncatedString(c.Address.PublicKey))
253+
261254
c.sendPong <- struct{}{}
262255
case *Pong: // receive pong message notifies the "send" service to disable the 'pong timer exit'
263-
//c.log.Debugf("Received pong from %s", lib.BytesToTruncatedString(c.Address.PublicKey))
264256
c.receivedPong <- struct{}{}
265257
default: // unknown type results in slash and exiting the service
266258
c.Error(ErrUnknownP2PMsg(x), UnknownMessageSlash)
@@ -302,7 +294,7 @@ func (c *MultiConn) waitForAndHandleWireBytes(m *limiter.Monitor) (proto.Message
302294
// wraps a proto.Message into a universal Envelope, then converts to bytes and
303295
// sends them across the wire without violating the data flow rate limits
304296
// message may be a Packet, a Ping or a Pong
305-
func (c *MultiConn) sendPacket(packet *Packet, m *limiter.Monitor) (err lib.ErrorI) {
297+
func (c *MultiConn) sendPacket(packet *Packet, m *limiter.Monitor) {
306298
c.log.Debugf("Send Packet to %s (ID:%s, L:%d, E:%t), hash: %s",
307299
lib.BytesToTruncatedString(c.Address.PublicKey),
308300
lib.Topic_name[int32(packet.StreamId)],
@@ -311,19 +303,19 @@ func (c *MultiConn) sendPacket(packet *Packet, m *limiter.Monitor) (err lib.Erro
311303
crypto.ShortHashString(packet.Bytes),
312304
)
313305
// send packet as message over the wire
314-
err = c.sendWireBytes(packet, m)
306+
c.sendWireBytes(packet, m)
315307
return
316308
}
317309

318310
// sendWireBytes() a rate limited writer of outbound bytes to the wire
319311
// wraps a proto.Message into a universal Envelope, then converts to bytes and
320312
// sends them across the wire without violating the data flow rate limits
321313
// message may be a Packet, a Ping or a Pong
322-
func (c *MultiConn) sendWireBytes(message proto.Message, m *limiter.Monitor) (err lib.ErrorI) {
314+
func (c *MultiConn) sendWireBytes(message proto.Message, m *limiter.Monitor) {
323315
// convert the proto.Message into a proto.Any
324316
a, err := lib.NewAny(message)
325317
if err != nil {
326-
return err
318+
c.Error(err)
327319
}
328320
// restrict the instantaneous data flow to rate bytes per second
329321
// Limit() request maxPacketSize bytes from the limiter and the limiter

p2p/p2p.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,6 @@ var blockedCountries = []string{
415415
"LY", // Libya
416416
"ML", // Mali
417417
"NI", // Nicaragua
418-
"PR", // Puerto Rico
419418
"RU", // Russia
420419
"SD", // Sudan
421420
"SS", // South Sudan

0 commit comments

Comments
 (0)