#lang scheme/base
(require scheme/contract
srfi/26/cut
syntax/boundmap
(file "base.ss"))
(define info-cache (make-module-identifier-mapping))
(define-struct site-info (site-id controller-ids) #:transparent)
(define (site-info-set! site-id controller-ids)
(module-identifier-mapping-put! info-cache site-id (make-site-info site-id controller-ids)))
(define (site-info-set? id)
(with-handlers ([exn? (lambda _ #f)])
(module-identifier-mapping-get info-cache id)
#t))
(define (site-info-ref id [default (cut raise-syntax-error #f "No such site." #f id)])
(module-identifier-mapping-get info-cache id default))
(provide/contract
[struct site-info ([site-id identifier?]
[controller-ids (listof identifier?)])]
[site-info-set! (-> identifier? (listof identifier?) void?)]
[site-info-set? (-> identifier? boolean?)]
[site-info-ref (->* (identifier?) (procedure?) (or/c site-info? false/c))])