Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
2bd5510
feat(sensor): broadcast block, txs, and hashes
minhd-vu Oct 14, 2025
7e19682
Merge branch 'main' into minhd-vu/sensor-broadcast
minhd-vu Jan 20, 2026
ae4bc71
chore: revert ulxly changes to match main
minhd-vu Jan 20, 2026
1eafffd
fix: make gen
minhd-vu Jan 20, 2026
006e1f7
Merge branch 'main' into minhd-vu/sensor-broadcast
minhd-vu Feb 19, 2026
9b73909
fix: comments
minhd-vu Feb 19, 2026
bf9719a
fix: flag name
minhd-vu Feb 19, 2026
1e2306a
fix: expiresAt
minhd-vu Feb 19, 2026
8041cc6
fix: graceful shutdown
minhd-vu Feb 19, 2026
5409e0b
fix: handle disconnects for peer conns
minhd-vu Feb 19, 2026
c474e29
fix: call cancel()
minhd-vu Feb 20, 2026
6493219
fix: revert some graceful shutdown handling
minhd-vu Feb 20, 2026
1ef0115
fix: revert rpc.go
minhd-vu Feb 20, 2026
7a25ede
fix: revert again
minhd-vu Feb 20, 2026
b33386c
fix: one more revert
minhd-vu Feb 20, 2026
5f6fd24
fix: lint
minhd-vu Feb 20, 2026
0aec080
fix: rename
minhd-vu Feb 20, 2026
7fa8aae
fix: async tx announcements and goroutine cleanup
minhd-vu Feb 25, 2026
be15860
Merge branch 'main' into minhd-vu/sensor-broadcast
minhd-vu Feb 25, 2026
5d4ce45
fix: remove comment
minhd-vu Feb 25, 2026
865141a
feat(sensor): support more rpc methods
minhd-vu Feb 20, 2026
6db99fa
Merge branch 'main' into minhd-vu/sensor-broadcast
minhd-vu Feb 28, 2026
3b66e34
fix: lint
minhd-vu Feb 28, 2026
840ead4
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Feb 28, 2026
97b6e01
docs: make gen
minhd-vu Feb 28, 2026
1499508
Merge branch 'main' into minhd-vu/sensor-broadcast
minhd-vu Mar 2, 2026
da98090
fix: lint
minhd-vu Mar 2, 2026
b0e0544
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Mar 2, 2026
15494bd
fix: lint
minhd-vu Mar 2, 2026
743f953
fix: protocol lengths
minhd-vu Mar 2, 2026
e68b0ba
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Mar 2, 2026
9ccc61d
fix: use bor status packet
minhd-vu Mar 2, 2026
8a107c6
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Mar 2, 2026
6584163
feat: enable pprof lock profiling
minhd-vu Mar 3, 2026
832a463
fix: lock contention
minhd-vu Mar 3, 2026
2eed8ea
fix: use min
minhd-vu Mar 3, 2026
dfcabbd
fix: increase tx cache size
minhd-vu Mar 3, 2026
25ef16c
feat: add protocol version
minhd-vu Mar 3, 2026
abf1c2b
fix: protocol
minhd-vu Mar 3, 2026
0b87513
feat: improve logging
minhd-vu Mar 3, 2026
1af2505
docs: make gen
minhd-vu Mar 3, 2026
95a00e2
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Mar 3, 2026
cf1dae5
fix: merge conflicts
minhd-vu Mar 3, 2026
5d89c67
feat: bloomset
minhd-vu Mar 3, 2026
4408b34
feat: datastructures package
minhd-vu Mar 3, 2026
0b1b33a
Merge branch 'main' into minhd-vu/sensor-broadcast
minhd-vu Mar 3, 2026
2f5585c
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Mar 3, 2026
99a460c
fix: improve lru
minhd-vu Mar 3, 2026
e647649
fix: lint
minhd-vu Mar 3, 2026
ea8cd0f
fix: lint
minhd-vu Mar 3, 2026
9c807af
fix: suggestions
minhd-vu Mar 3, 2026
65e07d1
fix: remove unused
minhd-vu Mar 3, 2026
3b82419
feat: peek many with keys
minhd-vu Mar 3, 2026
2d0e747
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Mar 3, 2026
73bbd26
fix: missing functions
minhd-vu Mar 3, 2026
00de538
fix: goroutine leak
minhd-vu Mar 3, 2026
9fe6c08
Merge branch 'minhd-vu/sensor-broadcast' into minhd-vu/rpc-methods
minhd-vu Mar 3, 2026
c46e2e8
fix: gas methods
minhd-vu Mar 3, 2026
a48a0fe
fix: cleanup
minhd-vu Mar 3, 2026
015df74
Merge branch 'main' into minhd-vu/sensor-broadcast
minhd-vu Mar 4, 2026
73a6c0a
fix: add space
minhd-vu Mar 4, 2026
b33b162
fix: add space in lru
minhd-vu Mar 4, 2026
e58a58f
fix: lint
minhd-vu Mar 4, 2026
aa557bc
Merge branch 'main' into minhd-vu/rpc-methods
minhd-vu Mar 11, 2026
89f5fd8
feat: include latest block hash and number in sensor api
minhd-vu Mar 19, 2026
91514eb
feat: proxy rpc calls
minhd-vu Mar 19, 2026
416c127
fix: race condition
minhd-vu Mar 19, 2026
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
11 changes: 11 additions & 0 deletions cmd/p2p/sensor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
type peerData struct {
Name string `json:"name"`
ProtocolVersion uint `json:"protocol_version"`
BlockHash string `json:"block_hash,omitempty"`
BlockNumber uint64 `json:"block_number,omitempty"`
Received p2p.MessageCount `json:"received"`
Sent p2p.MessageCount `json:"sent"`
PacketsReceived p2p.MessageCount `json:"packets_received"`
Expand Down Expand Up @@ -58,7 +60,7 @@
// handleAPI sets up the API for interacting with the sensor. All endpoints
// return information about the sensor node and all connected peers, including
// the types and counts of eth packets sent and received by each peer.
func handleAPI(server *ethp2p.Server, conns *p2p.Conns) {

Check failure on line 63 in cmd/p2p/sensor/api.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=0xPolygon_polygon-cli&issues=AZ0EsRrQuLbE7AhQd-dq&open=AZ0EsRrQuLbE7AhQd-dq&pullRequest=862
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
Expand All @@ -84,9 +86,18 @@
continue
}

// Get latest block info for this peer
blockHash, blockNumber := conns.GetPeerLatestBlock(peerID)
var blockHashStr string
if blockNumber > 0 {
blockHashStr = blockHash.Hex()
}

peers[url] = peerData{
Name: conns.GetPeerName(peerID),
ProtocolVersion: conns.GetPeerVersion(peerID),
BlockHash: blockHashStr,
BlockNumber: blockNumber,
Received: messages.Received,
Sent: messages.Sent,
PacketsReceived: messages.PacketsReceived,
Expand Down
Loading
Loading