go-p2p/node/compat.go
Snider 85de30a528 feat(compat): implement spec-described aliases across all packages
Add compatibility aliases documented in specs but missing from code:

- node: NewNodeManagerWithPaths, NewPeerRegistryWithPath (deprecated
  constructor aliases), RegisterWithTransport (deprecated method alias),
  ConnectedPeers (count alias), GetLogsPayload (type alias)
- levin: Short-form Value constructors (Uint64Val, StringVal, ObjectVal,
  etc.) matching spec naming
- logging: WithComponent, GetLevel, GetGlobal (deprecated method aliases)
- ueps: TagCurrentLay, TagTargetLay (short-form tag constant aliases)

All aliases delegate to the canonical AX-compliant names. Tests cover
every alias with round-trip verification where applicable.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-31 12:25:22 +01:00

46 lines
1.6 KiB
Go

// SPDX-License-Identifier: EUPL-1.2
// This file provides deprecated compatibility aliases and type aliases
// for spec compatibility. Canonical names are defined in their respective
// source files; these aliases exist so that code written against the spec
// documentation continues to compile.
package node
// NewNodeManagerWithPaths loads or creates a node identity store at explicit paths.
// Deprecated: Use NewNodeManagerFromPaths instead.
//
// nodeManager, err := NewNodeManagerWithPaths("/srv/p2p/private.key", "/srv/p2p/node.json")
func NewNodeManagerWithPaths(keyPath, configPath string) (*NodeManager, error) {
return NewNodeManagerFromPaths(keyPath, configPath)
}
// NewPeerRegistryWithPath loads or creates a peer registry at an explicit path.
// Deprecated: Use NewPeerRegistryFromPath instead.
//
// peerRegistry, err := NewPeerRegistryWithPath("/srv/p2p/peers.json")
func NewPeerRegistryWithPath(peersPath string) (*PeerRegistry, error) {
return NewPeerRegistryFromPath(peersPath)
}
// RegisterWithTransport installs the worker message handler on the transport.
// Deprecated: Use RegisterOnTransport instead.
//
// worker.RegisterWithTransport()
func (w *Worker) RegisterWithTransport() {
w.RegisterOnTransport()
}
// ConnectedPeers returns the number of connected peers.
// Deprecated: Use ConnectedPeerCount instead.
//
// count := transport.ConnectedPeers()
func (t *Transport) ConnectedPeers() int {
return t.ConnectedPeerCount()
}
// GetLogsPayload is an alias for LogsRequestPayload.
// Provided for spec compatibility.
//
// payload := GetLogsPayload{MinerName: "xmrig-0", Lines: 100}
type GetLogsPayload = LogsRequestPayload