From ab72a155c6ddaaad7d3a5dfc7cd018ed48fd0e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 25 Nov 2025 14:25:55 +0100 Subject: [PATCH] store: Move low-level protocol bit-twiddling to (guix remote-procedures). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/store.scm (%protocol-version, %worker-magic-1, %worker-magic-2) (protocol-major, protocol-minor, protocol-version): Move to… * guix/remote-procedures.scm: … here. Change-Id: Idbb23e63ab6314aa7e9ce0e3e5aa835be85c27d9 Signed-off-by: Ludovic Courtès --- guix/remote-procedures.scm | 29 ++++++++++++++++++++++++++++- guix/store.scm | 12 ------------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/guix/remote-procedures.scm b/guix/remote-procedures.scm index 3f4f9babce..dca491a76d 100644 --- a/guix/remote-procedures.scm +++ b/guix/remote-procedures.scm @@ -18,7 +18,14 @@ (define-module (guix remote-procedures) #:use-module (guix serialization) - #:export (visit-remote-procedures + #:export (%protocol-version + %worker-magic-1 + %worker-magic-2 + protocol-major + protocol-minor + protocol-version + + visit-remote-procedures id: returns: remote-procedure-id @@ -37,6 +44,26 @@ ;;; ;;; Code: +(define %protocol-version + ;; Version of the currently-implemented protocol. + #x164) + +;; Values sent by the client and then the server upon handshake. +(define %worker-magic-1 #x6e697863) ; "nixc" +(define %worker-magic-2 #x6478696f) ; "dxio" + +(define (protocol-major magic) + "Extract from MAGIC, an integer, the protocol major version." + (logand magic #xff00)) + +(define (protocol-minor magic) + "Extract from MAGIC, an integer, the protocol minor version." + (logand magic #x00ff)) + +(define (protocol-version major minor) + "Return an integer representing protocol version MAJOR and MINOR." + (logior major minor)) + (define-syntax define-remote-procedures (syntax-rules (define) ((_ walk definition ...) diff --git a/guix/store.scm b/guix/store.scm index 7d0626372a..4fd42cc658 100644 --- a/guix/store.scm +++ b/guix/store.scm @@ -211,18 +211,6 @@ derivation-log-file log-file)) -(define %protocol-version #x164) - -(define %worker-magic-1 #x6e697863) ; "nixc" -(define %worker-magic-2 #x6478696f) ; "dxio" - -(define (protocol-major magic) - (logand magic #xff00)) -(define (protocol-minor magic) - (logand magic #x00ff)) -(define (protocol-version major minor) - (logior major minor)) - (define %default-socket-path (string-append %state-directory "/daemon-socket/socket"))