Phase 5: Rework protocol package and implement application layer #5

Merged
krendelhoff merged 7 commits from phase-5-basic-client-server into master 2025-08-23 08:36:45 +03:00
Showing only changes of commit c7b930c935 - Show all commits

View file

@ -0,0 +1,31 @@
package protocol
// MessageType represents the type of protocol message
type MessageType byte
const (
ChallengeRequestType MessageType = 0x01
SolutionRequestType MessageType = 0x03
// Response types (for responses.go)
ChallengeResponseType MessageType = 0x02
QuoteResponseType MessageType = 0x04
ErrorResponseType MessageType = 0x05
)
// Error codes as defined in protocol specification
const (
ErrMalformedMessage = "MALFORMED_MESSAGE"
ErrInvalidChallenge = "INVALID_CHALLENGE"
ErrInvalidSolution = "INVALID_SOLUTION"
ErrExpiredChallenge = "EXPIRED_CHALLENGE"
ErrRateLimited = "RATE_LIMITED"
ErrServerError = "SERVER_ERROR"
ErrTooManyConnections = "TOO_MANY_CONNECTIONS"
ErrDifficultyTooHigh = "DIFFICULTY_TOO_HIGH"
)
// Protocol constants
const (
MaxPayloadSize = 8 * 1024 // 8KB maximum payload size
HeaderSize = 5 // 1 byte type + 4 bytes length
)