diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2025-11-25 14:25:55 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2026-01-27 12:58:18 +0100 |
| commit | ab72a155c6ddaaad7d3a5dfc7cd018ed48fd0e09 (patch) | |
| tree | e10b7288741f8fab4d727e5cb578acbe0c069746 | |
| parent | 68f1f74fb8896a1f77d244eb1fee32055eba9e49 (diff) | |
store: Move low-level protocol bit-twiddling to (guix remote-procedures).
* 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 <ludo@gnu.org>
| -rw-r--r-- | guix/remote-procedures.scm | 29 | ||||
| -rw-r--r-- | guix/store.scm | 12 |
2 files changed, 28 insertions, 13 deletions
diff --git a/guix/remote-procedures.scm b/guix/remote-procedures.scm index 3f4f9babce7..dca491a76d3 100644 --- a/guix/remote-procedures.scm +++ b/guix/remote-procedures.scm | |||
| @@ -18,7 +18,14 @@ | |||
| 18 | 18 | ||
| 19 | (define-module (guix remote-procedures) | 19 | (define-module (guix remote-procedures) |
| 20 | #:use-module (guix serialization) | 20 | #:use-module (guix serialization) |
| 21 | #:export (visit-remote-procedures | 21 | #:export (%protocol-version |
| 22 | %worker-magic-1 | ||
| 23 | %worker-magic-2 | ||
| 24 | protocol-major | ||
| 25 | protocol-minor | ||
| 26 | protocol-version | ||
| 27 | |||
| 28 | visit-remote-procedures | ||
| 22 | id: | 29 | id: |
| 23 | returns: | 30 | returns: |
| 24 | remote-procedure-id | 31 | remote-procedure-id |
| @@ -37,6 +44,26 @@ | |||
| 37 | ;;; | 44 | ;;; |
| 38 | ;;; Code: | 45 | ;;; Code: |
| 39 | 46 | ||
| 47 | (define %protocol-version | ||
| 48 | ;; Version of the currently-implemented protocol. | ||
| 49 | #x164) | ||
| 50 | |||
| 51 | ;; Values sent by the client and then the server upon handshake. | ||
| 52 | (define %worker-magic-1 #x6e697863) ; "nixc" | ||
| 53 | (define %worker-magic-2 #x6478696f) ; "dxio" | ||
| 54 | |||
| 55 | (define (protocol-major magic) | ||
| 56 | "Extract from MAGIC, an integer, the protocol major version." | ||
| 57 | (logand magic #xff00)) | ||
| 58 | |||
| 59 | (define (protocol-minor magic) | ||
| 60 | "Extract from MAGIC, an integer, the protocol minor version." | ||
| 61 | (logand magic #x00ff)) | ||
| 62 | |||
| 63 | (define (protocol-version major minor) | ||
| 64 | "Return an integer representing protocol version MAJOR and MINOR." | ||
| 65 | (logior major minor)) | ||
| 66 | |||
| 40 | (define-syntax define-remote-procedures | 67 | (define-syntax define-remote-procedures |
| 41 | (syntax-rules (define) | 68 | (syntax-rules (define) |
| 42 | ((_ walk definition ...) | 69 | ((_ walk definition ...) |
diff --git a/guix/store.scm b/guix/store.scm index 7d0626372a8..4fd42cc6587 100644 --- a/guix/store.scm +++ b/guix/store.scm | |||
| @@ -211,18 +211,6 @@ | |||
| 211 | derivation-log-file | 211 | derivation-log-file |
| 212 | log-file)) | 212 | log-file)) |
| 213 | 213 | ||
| 214 | (define %protocol-version #x164) | ||
| 215 | |||
| 216 | (define %worker-magic-1 #x6e697863) ; "nixc" | ||
| 217 | (define %worker-magic-2 #x6478696f) ; "dxio" | ||
| 218 | |||
| 219 | (define (protocol-major magic) | ||
| 220 | (logand magic #xff00)) | ||
| 221 | (define (protocol-minor magic) | ||
| 222 | (logand magic #x00ff)) | ||
| 223 | (define (protocol-version major minor) | ||
| 224 | (logior major minor)) | ||
| 225 | |||
| 226 | (define %default-socket-path | 214 | (define %default-socket-path |
| 227 | (string-append %state-directory "/daemon-socket/socket")) | 215 | (string-append %state-directory "/daemon-socket/socket")) |
| 228 | 216 | ||
