Skip to content

Commit 230d6b7

Browse files
committed
fix: rename methods to be more idiomatic
1 parent 7067d04 commit 230d6b7

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

cmd/p2p/sensor/api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func handleAPI(server *ethp2p.Server, counter *prometheus.CounterVec, conns *p2p
6262
url := peer.Node().URLv4()
6363
peerID := peer.Node().ID().String()
6464
name := peer.Fullname()
65-
connectedAt := conns.GetPeerConnectedAt(peerID)
65+
connectedAt := conns.PeerConnectedAt(peerID)
6666
if connectedAt.IsZero() {
6767
continue
6868
}
@@ -79,8 +79,8 @@ func handleAPI(server *ethp2p.Server, counter *prometheus.CounterVec, conns *p2p
7979
peers[url] = msgs
8080
}
8181

82-
head := conns.GetHeadBlock()
83-
oldest := conns.GetOldestBlock()
82+
head := conns.HeadBlock()
83+
oldest := conns.OldestBlock()
8484

8585
data := apiData{
8686
ENR: server.NodeInfo().ENR,

cmd/p2p/sensor/sensor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ var SensorCmd = &cobra.Command{
284284
peersGauge.Set(float64(server.PeerCount()))
285285
db.WritePeers(cmd.Context(), server.Peers(), time.Now())
286286

287-
metrics.Update(conns.GetHeadBlock().Block, conns.GetOldestBlock())
287+
metrics.Update(conns.HeadBlock().Block, conns.OldestBlock())
288288

289289
urls := []string{}
290290
for _, peer := range server.Peers() {

p2p/conns.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ func (c *Conns) Nodes() []*enode.Node {
107107
return nodes
108108
}
109109

110-
// GetPeerConnectedAt returns the connection time for a peer by their ID.
110+
// PeerConnectedAt returns the connection time for a peer by their ID.
111111
// Returns zero time if the peer is not found.
112-
func (c *Conns) GetPeerConnectedAt(peerID string) time.Time {
112+
func (c *Conns) PeerConnectedAt(peerID string) time.Time {
113113
c.mu.RLock()
114114
defer c.mu.RUnlock()
115115

@@ -125,15 +125,15 @@ func (c *Conns) Blocks() *Cache[common.Hash, BlockCache] {
125125
return c.blocks
126126
}
127127

128-
// GetOldestBlock returns the oldest block the sensor will fetch parents for.
128+
// OldestBlock returns the oldest block the sensor will fetch parents for.
129129
// This is set once at initialization to the head block and acts as a floor
130130
// to prevent the sensor from crawling backwards indefinitely.
131-
func (c *Conns) GetOldestBlock() *types.Header {
131+
func (c *Conns) OldestBlock() *types.Header {
132132
return c.oldest.Get()
133133
}
134134

135-
// GetHeadBlock returns the current head block packet.
136-
func (c *Conns) GetHeadBlock() eth.NewBlockPacket {
135+
// HeadBlock returns the current head block packet.
136+
func (c *Conns) HeadBlock() eth.NewBlockPacket {
137137
return c.head.Get()
138138
}
139139

p2p/protocol.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func NewEthProtocol(version uint, opts EthProtocolOptions) ethp2p.Protocol {
103103
peerFullname: p.Fullname(),
104104
}
105105

106-
head := c.conns.GetHeadBlock()
106+
head := c.conns.HeadBlock()
107107
status := eth.StatusPacket{
108108
ProtocolVersion: uint32(version),
109109
NetworkID: opts.NetworkID,
@@ -310,7 +310,7 @@ func (c *conn) getParentBlock(ctx context.Context, header *types.Header) error {
310310
return nil
311311
}
312312

313-
oldestBlock := c.conns.GetOldestBlock()
313+
oldestBlock := c.conns.OldestBlock()
314314

315315
// Check cache first before querying the database
316316
cache, ok := c.conns.Blocks().Peek(header.ParentHash)

0 commit comments

Comments
 (0)