                                       (.getCert ^Enrollment enrollment))]
     (swap! client-lru-cache cache/evict cache-key)))
 
-(defn get-or-make-client [msp-id name priv-key cert & opts]
+(defrecord ClientOpts [roles account affiliation])
+
+(defn get-or-make-client [msp-id name priv-key cert opts]
   (let [cache-key (priv-key+cert->hash priv-key cert)
         lru-cache (swap! client-lru-cache cache/hit cache-key)]
     (if-let [existing-client (cache/lookup lru-cache cache-key)]

            [clojure-fabric.request :as request]
            [clojure-fabric.response :as response]
            [clojure.core.cache :as cache])
  (:import [org.hyperledger.fabric.sdk User Enrollment]
           [org.bouncycastle.jcajce.provider.asymmetric.ec BCECPrivateKey]))

(defonce client-lru-cache
  ;; FIXME: magic number
  (atom (cache/lru-cache-factory {} :threshold 64)))

(defn make-client [msp-id name priv-key cert & [{:keys [roles account affiliation]}]]
  (let [new-client (client/create-new-instance)]
    (client/set-crypto-suite new-client (crypto/get-crypto-suite))
    (client/set-user-context new-client 


;;;;;;;;;;; Ex
#_
(comment
  (defonce cli
   (get-or-make-client "Org1Msp"
                "PeerAdmin"
                (-> (slurp "resources/creds/cd96d5260ad4757551ed4a5a991e62130f8008a0bf996e4e4b84cd097a747fec-priv")
                    (keys/str->private-key))
                "-----BEGIN CERTIFICATE-----\nMIICGDCCAb+gAwIBAgIQFSxnLAGsu04zrFkAEwzn6zAKBggqhkjOPQQDAjBzMQsw\nCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy\nYW5jaXNjbzEZMBcGA1UEChMQb3JnMS5leGFtcGxlLmNvbTEcMBoGA1UEAxMTY2Eu\nb3JnMS5leGFtcGxlLmNvbTAeFw0xNzA4MzEwOTE0MzJaFw0yNzA4MjkwOTE0MzJa\nMFsxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\nYW4gRnJhbmNpc2NvMR8wHQYDVQQDDBZBZG1pbkBvcmcxLmV4YW1wbGUuY29tMFkw\nEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEV1dfmKxsFKWo7o6DNBIaIVebCCPAM9C/\nsLBt4pJRre9pWE987DjXZoZ3glc4+DoPMtTmBRqbPVwYcUvpbYY8p6NNMEswDgYD\nVR0PAQH/BAQDAgeAMAwGA1UdEwEB/wQCMAAwKwYDVR0jBCQwIoAgQjmqDc122u64\nugzacBhR0UUE0xqtGy3d26xqVzZeSXwwCgYIKoZIzj0EAwIDRwAwRAIgXMy26AEU\n/GUMPfCMs/nQjQME1ZxBHAYZtKEuRR361JsCIEg9BOZdIoioRivJC+ZUzvJUnkXu\no2HkWiuxLsibGxtE\n-----END CERTIFICATE-----\n"
                {}))
  
  (add-channel-end cli "mychannel" (map->OrdererOpts {:name "orderer0" :grpc-url "grpc://localhost:7050"}))
  (add-channel-end cli "mychannel" (map->PeerOpts {:name "peer0" :grpc-url "grpc://localhost:7051"}))

  )
#_
(comment
  ;; Copy from fabcar example
