refactor(node): remove legacy compatibility aliases
All checks were successful
Security Scan / security (push) Successful in 10s
Test / test (push) Successful in 1m29s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-03-30 21:27:45 +00:00
parent 7ce21cdba1
commit c03b3410e6
21 changed files with 59 additions and 319 deletions

View file

@ -98,11 +98,6 @@ func (l *Logger) ComponentLogger(component string) *Logger {
}
}
// Deprecated: use ComponentLogger.
func (l *Logger) WithComponent(component string) *Logger {
return l.ComponentLogger(component)
}
// SetLevel changes the minimum log level.
//
// logger.SetLevel(LevelDebug)
@ -121,11 +116,6 @@ func (l *Logger) Level() Level {
return l.level
}
// Deprecated: use Level.
func (l *Logger) GetLevel() Level {
return l.Level()
}
// Fields represents key-value pairs for structured logging.
//
// fields := Fields{"peer_id": "node-1", "attempt": 2}
@ -261,11 +251,6 @@ func Global() *Logger {
return globalLogger
}
// Deprecated: use Global.
func GetGlobal() *Logger {
return Global()
}
// SetGlobalLevel changes the global logger level.
//
// SetGlobalLevel(LevelDebug)

View file

@ -146,11 +146,6 @@ func (c *Controller) RemoteStats(peerID string) (*StatsPayload, error) {
return &stats, nil
}
// Deprecated: use RemoteStats.
func (c *Controller) GetRemoteStats(peerID string) (*StatsPayload, error) {
return c.RemoteStats(peerID)
}
// StartRemoteMiner requests a remote peer to start a miner with a given profile.
//
// err := controller.StartRemoteMiner("worker-1", "xmrig", "profile-1", nil)
@ -259,11 +254,6 @@ func (c *Controller) RemoteLogs(peerID, minerName string, lines int) ([]string,
return logs.Lines, nil
}
// Deprecated: use RemoteLogs.
func (c *Controller) GetRemoteLogs(peerID, minerName string, lines int) ([]string, error) {
return c.RemoteLogs(peerID, minerName, lines)
}
// AllStats fetches stats from all connected peers.
//
// statsByPeerID := controller.AllStats()
@ -295,11 +285,6 @@ func (c *Controller) AllStats() map[string]*StatsPayload {
return results
}
// Deprecated: use AllStats.
func (c *Controller) GetAllStats() map[string]*StatsPayload {
return c.AllStats()
}
// PingPeer sends a ping to a peer and refreshes that peer's metrics.
//
// rttMS, err := controller.PingPeer("worker-1")

View file

@ -136,7 +136,7 @@ func TestController_AutoConnect_Good(t *testing.T) {
tp.ClientReg.AddPeer(peer)
// Confirm no connection exists yet.
assert.Equal(t, 0, tp.Client.ConnectedPeers(), "should have no connections initially")
assert.Equal(t, 0, tp.Client.ConnectedPeerCount(), "should have no connections initially")
// Send a request — controller should auto-connect via transport before sending.
rtt, err := controller.PingPeer(serverIdentity.ID)
@ -144,10 +144,10 @@ func TestController_AutoConnect_Good(t *testing.T) {
assert.Greater(t, rtt, 0.0, "RTT should be positive after auto-connect")
// Verify connection was established.
assert.Equal(t, 1, tp.Client.ConnectedPeers(), "should have 1 connection after auto-connect")
assert.Equal(t, 1, tp.Client.ConnectedPeerCount(), "should have 1 connection after auto-connect")
}
func TestController_GetAllStats_Good(t *testing.T) {
func TestController_AllStats_Good(t *testing.T) {
// Controller node with connections to two independent worker servers.
controllerNM := newTestNodeManager(t, "controller", RoleController)
controllerReg := newTestPeerRegistry(t)
@ -341,7 +341,7 @@ func TestController_ConcurrentRequestsSamePeer_Ugly(t *testing.T) {
"all concurrent requests to the same peer should succeed")
}
func TestController_GetRemoteStats_Good(t *testing.T) {
func TestController_RemoteStats_Good(t *testing.T) {
controller, _, tp := setupControllerPair(t)
serverID := tp.ServerNode.Identity().ID
@ -368,7 +368,7 @@ func TestController_DisconnectFromPeer_Good(t *testing.T) {
controller, _, tp := setupControllerPair(t)
serverID := tp.ServerNode.Identity().ID
assert.Equal(t, 1, tp.Client.ConnectedPeers(), "should have 1 connection")
assert.Equal(t, 1, tp.Client.ConnectedPeerCount(), "should have 1 connection")
err := controller.DisconnectFromPeer(serverID)
require.NoError(t, err, "DisconnectFromPeer should succeed")
@ -590,7 +590,7 @@ func TestController_StopRemoteMiner_NoIdentity_Bad(t *testing.T) {
assert.Contains(t, err.Error(), "identity not initialized")
}
func TestController_GetRemoteLogs_Good(t *testing.T) {
func TestController_RemoteLogs_Good(t *testing.T) {
controller, _, tp := setupControllerPairWithMiner(t)
serverID := tp.ServerNode.Identity().ID
@ -601,7 +601,7 @@ func TestController_GetRemoteLogs_Good(t *testing.T) {
assert.Contains(t, lines[0], "started")
}
func TestController_GetRemoteLogs_LimitedLines_Good(t *testing.T) {
func TestController_RemoteLogs_LimitedLines_Good(t *testing.T) {
controller, _, tp := setupControllerPairWithMiner(t)
serverID := tp.ServerNode.Identity().ID
@ -610,7 +610,7 @@ func TestController_GetRemoteLogs_LimitedLines_Good(t *testing.T) {
assert.Len(t, lines, 1, "should return only 1 line")
}
func TestController_GetRemoteLogs_NoIdentity_Bad(t *testing.T) {
func TestController_RemoteLogs_NoIdentity_Bad(t *testing.T) {
tp := setupTestTransportPair(t)
keyPath, configPath := testNodeManagerPaths(t.TempDir())
nmNoID, err := NewNodeManagerFromPaths(keyPath, configPath)
@ -623,7 +623,7 @@ func TestController_GetRemoteLogs_NoIdentity_Bad(t *testing.T) {
assert.Contains(t, err.Error(), "identity not initialized")
}
func TestController_GetRemoteStats_WithMiners_Good(t *testing.T) {
func TestController_RemoteStats_WithMiners_Good(t *testing.T) {
controller, _, tp := setupControllerPairWithMiner(t)
serverID := tp.ServerNode.Identity().ID
@ -637,7 +637,7 @@ func TestController_GetRemoteStats_WithMiners_Good(t *testing.T) {
assert.Equal(t, 1234.5, stats.Miners[0].Hashrate)
}
func TestController_GetRemoteStats_NoIdentity_Bad(t *testing.T) {
func TestController_RemoteStats_NoIdentity_Bad(t *testing.T) {
tp := setupTestTransportPair(t)
keyPath, configPath := testNodeManagerPaths(t.TempDir())
nmNoID, err := NewNodeManagerFromPaths(keyPath, configPath)
@ -671,7 +671,7 @@ func TestController_ConnectToPeer_Success_Good(t *testing.T) {
err := controller.ConnectToPeer(serverIdentity.ID)
require.NoError(t, err, "ConnectToPeer should succeed")
assert.Equal(t, 1, tp.Client.ConnectedPeers(), "should have 1 connection after ConnectToPeer")
assert.Equal(t, 1, tp.Client.ConnectedPeerCount(), "should have 1 connection after ConnectToPeer")
}
func TestController_HandleResponse_NonReply_Good(t *testing.T) {

View file

@ -145,19 +145,10 @@ var (
// the safety threshold.
ErrorThreatScoreExceeded = core.E("Dispatcher.Dispatch", core.Sprintf("packet rejected: threat score exceeds safety threshold (%d)", ThreatScoreThreshold), nil)
// Deprecated: use ErrorThreatScoreExceeded.
ErrThreatScoreExceeded = ErrorThreatScoreExceeded
// ErrorUnknownIntent is returned when no handler is registered for the
// packet's IntentID.
ErrorUnknownIntent = core.E("Dispatcher.Dispatch", "packet dropped: unknown intent", nil)
// Deprecated: use ErrorUnknownIntent.
ErrUnknownIntent = ErrorUnknownIntent
// ErrorNilPacket is returned when a nil packet is passed to Dispatch.
ErrorNilPacket = core.E("Dispatcher.Dispatch", "nil packet", nil)
// Deprecated: use ErrorNilPacket.
ErrNilPacket = ErrorNilPacket
)

View file

@ -78,13 +78,13 @@ func TestDispatcher_ThreatCircuitBreaker_Good(t *testing.T) {
{
name: "score just above threshold is rejected",
threatScore: ThreatScoreThreshold + 1,
wantErr: ErrThreatScoreExceeded,
wantErr: ErrorThreatScoreExceeded,
dispatched: false,
},
{
name: "maximum uint16 score is rejected",
threatScore: 65535,
wantErr: ErrThreatScoreExceeded,
wantErr: ErrorThreatScoreExceeded,
dispatched: false,
},
{
@ -130,7 +130,7 @@ func TestDispatcher_UnknownIntentDropped_Bad(t *testing.T) {
pkt := makePacket(0x42, 0, []byte("unknown"))
err := d.Dispatch(pkt)
assert.ErrorIs(t, err, ErrUnknownIntent)
assert.ErrorIs(t, err, ErrorUnknownIntent)
}
func TestDispatcher_MultipleHandlersCorrectRouting_Good(t *testing.T) {
@ -193,10 +193,10 @@ func TestDispatcher_MultipleHandlersCorrectRouting_Good(t *testing.T) {
}
func TestDispatcher_NilAndEmptyPayload_Ugly(t *testing.T) {
t.Run("nil packet returns ErrNilPacket", func(t *testing.T) {
t.Run("nil packet returns ErrorNilPacket", func(t *testing.T) {
d := NewDispatcher()
err := d.Dispatch(nil)
assert.ErrorIs(t, err, ErrNilPacket)
assert.ErrorIs(t, err, ErrorNilPacket)
})
t.Run("nil payload is delivered to handler", func(t *testing.T) {
@ -327,13 +327,13 @@ func TestDispatcher_ReplaceHandler_Good(t *testing.T) {
func TestDispatcher_ThreatBlocksBeforeRouting_Good(t *testing.T) {
// Verify that the circuit breaker fires before intent routing,
// so even an unknown intent returns ErrThreatScoreExceeded (not ErrUnknownIntent).
// so even an unknown intent returns ErrorThreatScoreExceeded (not ErrorUnknownIntent).
d := NewDispatcher()
pkt := makePacket(0x42, ThreatScoreThreshold+1, []byte("hostile"))
err := d.Dispatch(pkt)
assert.ErrorIs(t, err, ErrThreatScoreExceeded,
assert.ErrorIs(t, err, ErrorThreatScoreExceeded,
"threat circuit breaker should fire before intent routing")
}

View file

@ -8,13 +8,7 @@ var (
// a node identity but none has been generated or loaded.
ErrorIdentityNotInitialized = core.E("node", "node identity not initialized", nil)
// Deprecated: use ErrorIdentityNotInitialized.
ErrIdentityNotInitialized = ErrorIdentityNotInitialized
// ErrorMinerManagerNotConfigured is returned when a miner operation is
// attempted but no MinerManager has been set on the Worker.
ErrorMinerManagerNotConfigured = core.E("node", "miner manager not configured", nil)
// Deprecated: use ErrorMinerManagerNotConfigured.
ErrMinerManagerNotConfigured = ErrorMinerManagerNotConfigured
)

View file

@ -126,11 +126,6 @@ func NewNodeManagerFromPaths(keyPath, configPath string) (*NodeManager, error) {
return nm, nil
}
// Deprecated: use NewNodeManagerFromPaths.
func NewNodeManagerWithPaths(keyPath, configPath string) (*NodeManager, error) {
return NewNodeManagerFromPaths(keyPath, configPath)
}
// HasIdentity returns true if a node identity has been initialized.
func (n *NodeManager) HasIdentity() bool {
n.mu.RLock()
@ -152,11 +147,6 @@ func (n *NodeManager) Identity() *NodeIdentity {
return &identity
}
// Deprecated: use Identity.
func (n *NodeManager) GetIdentity() *NodeIdentity {
return n.Identity()
}
// GenerateIdentity writes a new node identity for the given name and role.
//
// err := nodeManager.GenerateIdentity("worker-1", RoleWorker)

View file

@ -116,9 +116,9 @@ func TestIntegration_FullNodeLifecycle_Good(t *testing.T) {
// Allow server-side goroutines to register the connection.
time.Sleep(100 * time.Millisecond)
assert.Equal(t, 1, controllerTransport.ConnectedPeers(),
assert.Equal(t, 1, controllerTransport.ConnectedPeerCount(),
"controller should have 1 connected peer")
assert.Equal(t, 1, workerTransport.ConnectedPeers(),
assert.Equal(t, 1, workerTransport.ConnectedPeerCount(),
"worker should have 1 connected peer")
// Verify the peer's real identity is stored.
@ -199,7 +199,7 @@ func TestIntegration_FullNodeLifecycle_Good(t *testing.T) {
parsed3, err := ueps.ReadAndVerify(bufio.NewReader(bytes.NewReader(wireData3)), sharedSecret)
require.NoError(t, err)
err = dispatcher.Dispatch(parsed3)
assert.ErrorIs(t, err, ErrThreatScoreExceeded,
assert.ErrorIs(t, err, ErrorThreatScoreExceeded,
"high-threat packet should be dropped by circuit breaker")
// Compute handler should NOT have been called again.
assert.Equal(t, int32(1), computeReceived.Load())
@ -232,7 +232,7 @@ func TestIntegration_FullNodeLifecycle_Good(t *testing.T) {
time.Sleep(200 * time.Millisecond)
// After graceful close, the controller should have 0 peers.
assert.Equal(t, 0, controllerTransport.ConnectedPeers(),
assert.Equal(t, 0, controllerTransport.ConnectedPeerCount(),
"controller should have 0 peers after graceful close")
}
@ -310,7 +310,7 @@ func TestIntegration_MultiPeerTopology_Good(t *testing.T) {
}
time.Sleep(100 * time.Millisecond)
assert.Equal(t, numWorkers, controllerTransport.ConnectedPeers(),
assert.Equal(t, numWorkers, controllerTransport.ConnectedPeerCount(),
"controller should be connected to all workers")
controller := NewController(controllerNM, controllerReg, controllerTransport)
@ -651,9 +651,9 @@ func TestIntegration_MessageSerialiseDeserialise_Good(t *testing.T) {
assert.Equal(t, originalStats, decryptedStats)
}
// TestIntegration_GetRemoteStats_EndToEnd tests the full stats retrieval flow
// TestIntegration_RemoteStats_EndToEnd tests the full stats retrieval flow
// across a real WebSocket connection.
func TestIntegration_GetRemoteStats_EndToEnd_Good(t *testing.T) {
func TestIntegration_RemoteStats_EndToEnd_Good(t *testing.T) {
tp := setupTestTransportPair(t)
worker := NewWorker(tp.ServerNode, tp.Server)

View file

@ -73,7 +73,7 @@ func TestConnection_Response_Good(t *testing.T) {
receiver := NewConnection(b)
payload := []byte("response data")
retCode := ReturnErrFormat
retCode := ReturnErrorFormat
errCh := make(chan error, 1)
go func() {
@ -120,7 +120,7 @@ func TestConnection_PayloadTooBig_Bad(t *testing.T) {
_, _, err := receiver.ReadPacket()
require.Error(t, err)
assert.ErrorIs(t, err, ErrPayloadTooBig)
assert.ErrorIs(t, err, ErrorPayloadTooBig)
require.NoError(t, <-errCh)
}

View file

@ -26,15 +26,6 @@ const (
ReturnErrorConnection int32 = -1
ReturnErrorFormat int32 = -7
ReturnErrorSignature int32 = -13
// Deprecated: use ReturnErrorConnection.
ReturnErrConnection = ReturnErrorConnection
// Deprecated: use ReturnErrorFormat.
ReturnErrFormat = ReturnErrorFormat
// Deprecated: use ReturnErrorSignature.
ReturnErrSignature = ReturnErrorSignature
)
// Command IDs for the CryptoNote P2P layer.
@ -54,12 +45,6 @@ const (
var (
ErrorBadSignature = core.E("levin", "bad signature", nil)
ErrorPayloadTooBig = core.E("levin", "payload exceeds maximum size", nil)
// Deprecated: use ErrorBadSignature.
ErrBadSignature = ErrorBadSignature
// Deprecated: use ErrorPayloadTooBig.
ErrPayloadTooBig = ErrorPayloadTooBig
)
// Header is the 33-byte packed header that prefixes every Levin message.

View file

@ -74,11 +74,11 @@ func TestHeader_EncodeHeader_NegativeReturnCode_Good(t *testing.T) {
PayloadSize: 0,
ExpectResponse: false,
Command: CommandHandshake,
ReturnCode: ReturnErrFormat,
ReturnCode: ReturnErrorFormat,
}
buf := EncodeHeader(h)
rc := int32(binary.LittleEndian.Uint32(buf[21:25]))
assert.Equal(t, ReturnErrFormat, rc)
assert.Equal(t, ReturnErrorFormat, rc)
}
func TestHeader_DecodeHeader_RoundTrip_Ugly(t *testing.T) {
@ -87,7 +87,7 @@ func TestHeader_DecodeHeader_RoundTrip_Ugly(t *testing.T) {
PayloadSize: 1024,
ExpectResponse: true,
Command: CommandTimedSync,
ReturnCode: ReturnErrConnection,
ReturnCode: ReturnErrorConnection,
Flags: 0,
ProtocolVersion: 0,
}
@ -140,7 +140,7 @@ func TestHeader_DecodeHeader_BadSignature_Bad(t *testing.T) {
buf := EncodeHeader(h)
_, err := DecodeHeader(buf)
require.Error(t, err)
assert.ErrorIs(t, err, ErrBadSignature)
assert.ErrorIs(t, err, ErrorBadSignature)
}
func TestHeader_DecodeHeader_PayloadTooBig_Bad(t *testing.T) {
@ -152,7 +152,7 @@ func TestHeader_DecodeHeader_PayloadTooBig_Bad(t *testing.T) {
buf := EncodeHeader(h)
_, err := DecodeHeader(buf)
require.Error(t, err)
assert.ErrorIs(t, err, ErrPayloadTooBig)
assert.ErrorIs(t, err, ErrorPayloadTooBig)
}
func TestHeader_DecodeHeader_MaxPayloadExact_Ugly(t *testing.T) {

View file

@ -46,24 +46,6 @@ var (
ErrorStorageNameTooLong = core.E("levin.storage", "entry name exceeds 255 bytes", nil)
ErrorStorageTypeMismatch = core.E("levin.storage", "value type mismatch", nil)
ErrorStorageUnknownType = core.E("levin.storage", "unknown type tag", nil)
// Deprecated: use ErrorStorageBadSignature.
ErrStorageBadSignature = ErrorStorageBadSignature
// Deprecated: use ErrorStorageTruncated.
ErrStorageTruncated = ErrorStorageTruncated
// Deprecated: use ErrorStorageBadVersion.
ErrStorageBadVersion = ErrorStorageBadVersion
// Deprecated: use ErrorStorageNameTooLong.
ErrStorageNameTooLong = ErrorStorageNameTooLong
// Deprecated: use ErrorStorageTypeMismatch.
ErrStorageTypeMismatch = ErrorStorageTypeMismatch
// Deprecated: use ErrorStorageUnknownType.
ErrStorageUnknownType = ErrorStorageUnknownType
)
// Section is an ordered map of named values forming a portable storage section.
@ -190,54 +172,6 @@ func ObjectArrayValue(vs []Section) Value {
return Value{Type: ArrayFlag | TypeObject, objectArray: vs}
}
// Deprecated: use Uint64Value.
func Uint64Val(v uint64) Value { return Uint64Value(v) }
// Deprecated: use Uint32Value.
func Uint32Val(v uint32) Value { return Uint32Value(v) }
// Deprecated: use Uint16Value.
func Uint16Val(v uint16) Value { return Uint16Value(v) }
// Deprecated: use Uint8Value.
func Uint8Val(v uint8) Value { return Uint8Value(v) }
// Deprecated: use Int64Value.
func Int64Val(v int64) Value { return Int64Value(v) }
// Deprecated: use Int32Value.
func Int32Val(v int32) Value { return Int32Value(v) }
// Deprecated: use Int16Value.
func Int16Val(v int16) Value { return Int16Value(v) }
// Deprecated: use Int8Value.
func Int8Val(v int8) Value { return Int8Value(v) }
// Deprecated: use BoolValue.
func BoolVal(v bool) Value { return BoolValue(v) }
// Deprecated: use DoubleValue.
func DoubleVal(v float64) Value { return DoubleValue(v) }
// Deprecated: use StringValue.
func StringVal(v []byte) Value { return StringValue(v) }
// Deprecated: use ObjectValue.
func ObjectVal(s Section) Value { return ObjectValue(s) }
// Deprecated: use Uint64ArrayValue.
func Uint64ArrayVal(vs []uint64) Value { return Uint64ArrayValue(vs) }
// Deprecated: use Uint32ArrayValue.
func Uint32ArrayVal(vs []uint32) Value { return Uint32ArrayValue(vs) }
// Deprecated: use StringArrayValue.
func StringArrayVal(vs [][]byte) Value { return StringArrayValue(vs) }
// Deprecated: use ObjectArrayValue.
func ObjectArrayVal(vs []Section) Value { return ObjectArrayValue(vs) }
// ---------------------------------------------------------------------------
// Scalar accessors
// ---------------------------------------------------------------------------

View file

@ -25,15 +25,9 @@ const (
// ErrorVarintTruncated is returned when the buffer is too short.
var ErrorVarintTruncated = core.E("levin", "truncated varint", nil)
// Deprecated: use ErrorVarintTruncated.
var ErrVarintTruncated = ErrorVarintTruncated
// ErrorVarintOverflow is returned when the value is too large to encode.
var ErrorVarintOverflow = core.E("levin", "varint overflow", nil)
// Deprecated: use ErrorVarintOverflow.
var ErrVarintOverflow = ErrorVarintOverflow
// PackVarint encodes v using the epee portable-storage varint scheme.
// The low two bits of the first byte indicate the total encoded width;
// the remaining bits carry the value in little-endian order.

View file

@ -82,7 +82,7 @@ func TestVarint_RoundTrip_Ugly(t *testing.T) {
func TestVarint_UnpackVarint_EmptyInput_Ugly(t *testing.T) {
_, _, err := UnpackVarint([]byte{})
require.Error(t, err)
assert.ErrorIs(t, err, ErrVarintTruncated)
assert.ErrorIs(t, err, ErrorVarintTruncated)
}
func TestVarint_UnpackVarint_Truncated2Byte_Bad(t *testing.T) {
@ -91,7 +91,7 @@ func TestVarint_UnpackVarint_Truncated2Byte_Bad(t *testing.T) {
require.Len(t, buf, 2)
_, _, err := UnpackVarint(buf[:1])
require.Error(t, err)
assert.ErrorIs(t, err, ErrVarintTruncated)
assert.ErrorIs(t, err, ErrorVarintTruncated)
}
func TestVarint_UnpackVarint_Truncated4Byte_Bad(t *testing.T) {
@ -99,7 +99,7 @@ func TestVarint_UnpackVarint_Truncated4Byte_Bad(t *testing.T) {
require.Len(t, buf, 4)
_, _, err := UnpackVarint(buf[:2])
require.Error(t, err)
assert.ErrorIs(t, err, ErrVarintTruncated)
assert.ErrorIs(t, err, ErrorVarintTruncated)
}
func TestVarint_UnpackVarint_Truncated8Byte_Bad(t *testing.T) {
@ -107,7 +107,7 @@ func TestVarint_UnpackVarint_Truncated8Byte_Bad(t *testing.T) {
require.Len(t, buf, 8)
_, _, err := UnpackVarint(buf[:4])
require.Error(t, err)
assert.ErrorIs(t, err, ErrVarintTruncated)
assert.ErrorIs(t, err, ErrorVarintTruncated)
}
func TestVarint_UnpackVarint_ExtraBytes_Good(t *testing.T) {

View file

@ -90,53 +90,6 @@ const (
MessageError MessageType = "error"
)
const (
// Deprecated: use MessageHandshake.
MsgHandshake = MessageHandshake
// Deprecated: use MessageHandshakeAck.
MsgHandshakeAck = MessageHandshakeAck
// Deprecated: use MessagePing.
MsgPing = MessagePing
// Deprecated: use MessagePong.
MsgPong = MessagePong
// Deprecated: use MessageDisconnect.
MsgDisconnect = MessageDisconnect
// Deprecated: use MessageGetStats.
MsgGetStats = MessageGetStats
// Deprecated: use MessageStats.
MsgStats = MessageStats
// Deprecated: use MessageStartMiner.
MsgStartMiner = MessageStartMiner
// Deprecated: use MessageStopMiner.
MsgStopMiner = MessageStopMiner
// Deprecated: use MessageMinerAck.
MsgMinerAck = MessageMinerAck
// Deprecated: use MessageDeploy.
MsgDeploy = MessageDeploy
// Deprecated: use MessageDeployAck.
MsgDeployAck = MessageDeployAck
// Deprecated: use MessageGetLogs.
MsgGetLogs = MessageGetLogs
// Deprecated: use MessageLogs.
MsgLogs = MessageLogs
// Deprecated: use MessageError.
MsgError = MessageError
)
// Message represents a P2P message between nodes.
//
// message, err := NewMessage(MessagePing, "controller", "worker", PingPayload{SentAt: time.Now().UnixMilli()})
@ -295,9 +248,6 @@ type LogsRequestPayload struct {
Since int64 `json:"since,omitempty"` // Unix timestamp, logs after this time
}
// Deprecated: use LogsRequestPayload.
type GetLogsPayload = LogsRequestPayload
// LogsPayload contains console log lines.
//
// payload := LogsPayload{MinerName: "xmrig-0", Lines: []string{"started"}}
@ -343,24 +293,6 @@ const (
ErrorCodeNotFound = 1003
ErrorCodeOperationFailed = 1004
ErrorCodeTimeout = 1005
// Deprecated: use ErrorCodeUnknown.
ErrCodeUnknown = ErrorCodeUnknown
// Deprecated: use ErrorCodeInvalidMessage.
ErrCodeInvalidMessage = ErrorCodeInvalidMessage
// Deprecated: use ErrorCodeUnauthorized.
ErrCodeUnauthorized = ErrorCodeUnauthorized
// Deprecated: use ErrorCodeNotFound.
ErrCodeNotFound = ErrorCodeNotFound
// Deprecated: use ErrorCodeOperationFailed.
ErrCodeOperationFailed = ErrorCodeOperationFailed
// Deprecated: use ErrorCodeTimeout.
ErrCodeTimeout = ErrorCodeTimeout
)
// NewErrorMessage builds an error response message for an existing request.

View file

@ -163,11 +163,6 @@ func NewPeerRegistryFromPath(peersPath string) (*PeerRegistry, error) {
return pr, nil
}
// Deprecated: use NewPeerRegistryFromPath.
func NewPeerRegistryWithPath(peersPath string) (*PeerRegistry, error) {
return NewPeerRegistryFromPath(peersPath)
}
// SetAuthMode changes how unknown peers are handled.
//
// registry.SetAuthMode(PeerAuthAllowlist)
@ -187,11 +182,6 @@ func (r *PeerRegistry) AuthMode() PeerAuthMode {
return r.authMode
}
// Deprecated: use AuthMode.
func (r *PeerRegistry) GetAuthMode() PeerAuthMode {
return r.AuthMode()
}
// AllowPublicKey adds a public key to the allowlist.
func (r *PeerRegistry) AllowPublicKey(publicKey string) {
r.allowedPublicKeyMu.Lock()
@ -350,11 +340,6 @@ func (r *PeerRegistry) Peer(id string) *Peer {
return &peerCopy
}
// Deprecated: use Peer.
func (r *PeerRegistry) GetPeer(id string) *Peer {
return r.Peer(id)
}
// ListPeers returns all registered peers.
func (r *PeerRegistry) ListPeers() []*Peer {
return slices.Collect(r.Peers())
@ -434,11 +419,6 @@ func (r *PeerRegistry) MarkConnected(id string, connected bool) {
}
}
// Deprecated: use MarkConnected.
func (r *PeerRegistry) SetConnected(id string, connected bool) {
r.MarkConnected(id, connected)
}
// Score adjustment constants
const (
ScoreSuccessIncrement = 1.0 // Increment for successful interaction
@ -529,11 +509,6 @@ func (r *PeerRegistry) PeersSortedByScore() []*Peer {
return peers
}
// Deprecated: use PeersSortedByScore.
func (r *PeerRegistry) GetPeersByScore() []*Peer {
return r.PeersSortedByScore()
}
// PeersByScore returns an iterator over peers sorted by score (highest first).
func (r *PeerRegistry) PeersByScore() iter.Seq[*Peer] {
return func(yield func(*Peer) bool) {
@ -606,11 +581,6 @@ func (r *PeerRegistry) ConnectedPeerList() []*Peer {
return slices.Collect(r.ConnectedPeers())
}
// Deprecated: use ConnectedPeerList.
func (r *PeerRegistry) GetConnectedPeers() []*Peer {
return r.ConnectedPeerList()
}
// ConnectedPeers returns an iterator over all currently connected peers.
// Each peer is a copy to prevent mutation.
func (r *PeerRegistry) ConnectedPeers() iter.Seq[*Peer] {

View file

@ -72,7 +72,7 @@ func TestPeer_Registry_AddPeer_Good(t *testing.T) {
}
}
func TestPeer_Registry_GetPeer_Good(t *testing.T) {
func TestPeer_Registry_Peer_Good(t *testing.T) {
pr, cleanup := setupTestPeerRegistry(t)
defer cleanup()
@ -242,7 +242,7 @@ func TestPeer_Registry_UpdateScore_Good(t *testing.T) {
}
}
func TestPeer_Registry_SetConnected_Good(t *testing.T) {
func TestPeer_Registry_MarkConnected_Good(t *testing.T) {
pr, cleanup := setupTestPeerRegistry(t)
defer cleanup()
@ -254,7 +254,7 @@ func TestPeer_Registry_SetConnected_Good(t *testing.T) {
pr.AddPeer(peer)
pr.SetConnected("connect-test", true)
pr.MarkConnected("connect-test", true)
updated := pr.Peer("connect-test")
if updated == nil {
@ -267,7 +267,7 @@ func TestPeer_Registry_SetConnected_Good(t *testing.T) {
t.Error("LastSeen should be set when connected")
}
pr.SetConnected("connect-test", false)
pr.MarkConnected("connect-test", false)
updated = pr.Peer("connect-test")
if updated == nil {
t.Fatal("expected peer to exist")
@ -277,7 +277,7 @@ func TestPeer_Registry_SetConnected_Good(t *testing.T) {
}
}
func TestPeer_Registry_GetConnectedPeers_Good(t *testing.T) {
func TestPeer_Registry_ConnectedPeerList_Good(t *testing.T) {
pr, cleanup := setupTestPeerRegistry(t)
defer cleanup()
@ -291,8 +291,8 @@ func TestPeer_Registry_GetConnectedPeers_Good(t *testing.T) {
pr.AddPeer(p)
}
pr.SetConnected("conn-1", true)
pr.SetConnected("conn-3", true)
pr.MarkConnected("conn-1", true)
pr.MarkConnected("conn-3", true)
connected := pr.ConnectedPeerList()
if len(connected) != 2 {
@ -604,7 +604,7 @@ func TestPeer_Registry_ScoreRecording_Good(t *testing.T) {
}
}
func TestPeer_Registry_GetPeersByScore_Good(t *testing.T) {
func TestPeer_Registry_PeersSortedByScore_Good(t *testing.T) {
pr, cleanup := setupTestPeerRegistry(t)
defer cleanup()
@ -800,12 +800,12 @@ func TestPeer_Registry_SelectNearestPeers_EmptyRegistry_Ugly(t *testing.T) {
}
}
func TestPeer_Registry_SetConnected_NonExistent_Bad(t *testing.T) {
func TestPeer_Registry_MarkConnected_NonExistent_Bad(t *testing.T) {
pr, cleanup := setupTestPeerRegistry(t)
defer cleanup()
// Should not panic for non-existent peer
pr.SetConnected("ghost-peer", true)
pr.MarkConnected("ghost-peer", true)
}
func TestPeer_Registry_Close_NoDirtyData_Ugly(t *testing.T) {

View file

@ -97,8 +97,3 @@ func ProtocolErrorCode(err error) int {
}
return 0
}
// Deprecated: use ProtocolErrorCode.
func GetProtocolErrorCode(err error) int {
return ProtocolErrorCode(err)
}

View file

@ -499,11 +499,6 @@ func (t *Transport) Connection(peerID string) *PeerConnection {
return t.conns[peerID]
}
// Deprecated: use Connection.
func (t *Transport) GetConnection(peerID string) *PeerConnection {
return t.Connection(peerID)
}
// handleWSUpgrade handles incoming WebSocket connections.
func (t *Transport) handleWSUpgrade(w http.ResponseWriter, r *http.Request) {
userAgent := r.Header.Get("User-Agent")
@ -1051,8 +1046,3 @@ func (t *Transport) ConnectedPeerCount() int {
defer t.mu.RUnlock()
return len(t.conns)
}
// Deprecated: use ConnectedPeerCount.
func (t *Transport) ConnectedPeers() int {
return t.ConnectedPeerCount()
}

View file

@ -219,11 +219,11 @@ func TestTransport_FullHandshake_Good(t *testing.T) {
// Allow server goroutines to register the connection
time.Sleep(50 * time.Millisecond)
if tp.Server.ConnectedPeers() != 1 {
t.Errorf("server connected peers: got %d, want 1", tp.Server.ConnectedPeers())
if tp.Server.ConnectedPeerCount() != 1 {
t.Errorf("server connected peers: got %d, want 1", tp.Server.ConnectedPeerCount())
}
if tp.Client.ConnectedPeers() != 1 {
t.Errorf("client connected peers: got %d, want 1", tp.Client.ConnectedPeers())
if tp.Client.ConnectedPeerCount() != 1 {
t.Errorf("client connected peers: got %d, want 1", tp.Client.ConnectedPeerCount())
}
// Verify peer identity was exchanged correctly
@ -539,8 +539,8 @@ func TestTransport_KeepaliveTimeout_Bad(t *testing.T) {
// Verify connection is established
time.Sleep(50 * time.Millisecond)
if tp.Server.ConnectedPeers() != 1 {
t.Fatalf("server should have 1 peer initially, got %d", tp.Server.ConnectedPeers())
if tp.Server.ConnectedPeerCount() != 1 {
t.Fatalf("server should have 1 peer initially, got %d", tp.Server.ConnectedPeerCount())
}
// Close the underlying WebSocket on the client side to simulate network failure.
@ -558,9 +558,9 @@ func TestTransport_KeepaliveTimeout_Bad(t *testing.T) {
for {
select {
case <-deadline:
t.Fatalf("server did not clean up connection: still has %d peers", tp.Server.ConnectedPeers())
t.Fatalf("server did not clean up connection: still has %d peers", tp.Server.ConnectedPeerCount())
default:
if tp.Server.ConnectedPeers() == 0 {
if tp.Server.ConnectedPeerCount() == 0 {
// Verify registry updated
peer := tp.ServerReg.Peer(clientID)
if peer != nil && peer.Connected {
@ -749,18 +749,18 @@ func TestTransport_NewTransport_DefaultMaxMessageSize_Good(t *testing.T) {
// The actual default is applied at usage time (readLoop, handleWSUpgrade)
}
func TestTransport_ConnectedPeers_Good(t *testing.T) {
func TestTransport_ConnectedPeerCount_Good(t *testing.T) {
tp := setupTestTransportPair(t)
if tp.Server.ConnectedPeers() != 0 {
t.Errorf("expected 0 connected peers initially, got %d", tp.Server.ConnectedPeers())
if tp.Server.ConnectedPeerCount() != 0 {
t.Errorf("expected 0 connected peers initially, got %d", tp.Server.ConnectedPeerCount())
}
tp.connectClient(t)
time.Sleep(50 * time.Millisecond)
if tp.Server.ConnectedPeers() != 1 {
t.Errorf("expected 1 connected peer after connect, got %d", tp.Server.ConnectedPeers())
if tp.Server.ConnectedPeerCount() != 1 {
t.Errorf("expected 1 connected peer after connect, got %d", tp.Server.ConnectedPeerCount())
}
}

View file

@ -419,8 +419,3 @@ func (w *Worker) handleDeploy(conn *PeerConnection, msg *Message) (*Message, err
func (w *Worker) RegisterOnTransport() {
w.transport.OnMessage(w.HandleMessage)
}
// Deprecated: use RegisterOnTransport.
func (w *Worker) RegisterWithTransport() {
w.RegisterOnTransport()
}