 
 (defrecord Client [channels crypto-suite user-context])
 
-(defrecord Channel [name peers orderers])
-
 ;;; new_chain
-(defn new-chain!
-  "Initializes a chain instance with the given name. This is really representing the \"Channel\"
-  (as explained above), and this call returns an empty object. To initialize the channel, a list of
-  participating endorsers and orderer peers must be configured first on the returned object.
-  Params:
-        name (str): The name of the chain, recommend using namespaces to avoid collision
-  Returns:
-        (Chain instance): The uninitialized chain instance."
+;;;
+;; "Initializes a chain instance with the given name. This is really representing the \"Channel\"
+;;   (as explained above), and this call returns an empty object. To initialize the channel, a list of
+;;   participating endorsers and orderer peers must be configured first on the returned object.
+;;   Params:
+;;         name (str): The name of the chain, recommend using namespaces to avoid collision
+;;   Returns:
+;;         (Chain instance): The uninitialized chain instance."
+(defn add-channel!
+  ([channel]
+   (add-channel! *client* channel))
+  ([client channel]
+   (let [found (get @(:channels client) name)]
+     (if (= found channel)
+       ;; Implementation Note
+       ;;       The spec doesn't say anything about existing channel.
+       ;;       Return if there is an existing channel with the name.
+       found
+       ;; replace or add
+       (swap! (:channels client) assoc name channel)))))
+
+#_
+(defn new-channel!
+  
   ([name]
-   (new-chain! *client* name))
+   (new-channel! *client* name))
   ([client name]
-   (new-chain! *client* name {}))
+   (new-channel! *client* name {}))
   ([client name opts]
    (let [channels (:channels client)]
      (if-let [found (get @channels name)]

        The target Peer(s) does not know anything about the chain"

  ([name peers]
   (query-chain-info *client* name peers))
  ([client name peers]
   (let [chain (get-chain name)]
     (if (= (get-peers chain) peers)
       (%query-chain-info chain peers)
       (throw (Exception. "The target Peer(s) does not know anything about the chain"))))))

(defonce query-channel-info query-chain-info)

;;;
;;;
(defonce ^:private client-state-store (atom {}))
;;; set_state_store
(defn set-state-store!
  "The SDK should have a built-in key value store implementation (suggest a file-based
  implementation to allow easy setup during development). But production systems would want

  Error:  The state store has not been set
        A chain does not exist under that name"
  ([name]
   (get-channel *client* name))
  ([client name]
   (if (nil? client)
     (throw (Exception. "The state store has not been set"))
