 
 (defn make-event-hub [user peer]
   (->EventHub user peer (async/chan (async/sliding-buffer default-sliding-buffer-size))
-              (async/chan) ;; command ch
+              (atom nil) ;;(async/chan) ;; command ch
               ;; block event ch & handlers
-              (async/chan (async/sliding-buffer default-sliding-buffer-size))
+              (atom nil) ;; (async/chan (async/sliding-buffer default-sliding-buffer-size))
               (atom {})  ;; block-event-handlers
               (atom {})  ;; tx-id->chan-fn-map
               (atom {})  ;; chaincode-id->chan-fn-map
-              (atom nil) ;; observer
               (atom nil) ;; event-go-loop
+              (atom nil) ;; start-time
+              (atom nil) ;; end-time
+              (atom nil) ;; managed-channel
               ))
 
 (def ^:dynamic *event-hub* nil)

                     block-event-handlers
                     tx-id->chan-fn-map
                     chaincode-id->chan-fn-map
                     observer
                     event-go-loop

                     ;; connected
                     ;; mtx
                     ;; grpc-client

  [fn]
  (->ChanFun (async/chan) fn))

(defmacro with-issuing-event-go-loop-command! [[event-hub command] & body]
  `(let [command-ch# (deref (:command-ch ~event-hub))]
     ~@body
     (when command-ch#
       (async/put! command-ch# ~command))))

(defn register-block-event
  ([fn-name fn]
   (register-block-event *event-hub* fn-name fn))
  ([event-hub fn-name fn]
   (with-issuing-event-go-loop-command! [event-hub :refresh]
     (swap! (:block-event-handlers event-hub) assoc fn-name fn))))

(defn unregister-block-event
  ([fn-name]
   (unregister-block-event *event-hub* fn-name))
  ([event-hub fn-name]
   (with-issuing-event-go-loop-command! [event-hub :refresh]
     (swap! (:block-event-handlers event-hub) dissoc fn-name))))

(defn- %unregister-event
  [event-hub id k]
  (let [ref-m (k event-hub)]
    (with-issuing-event-go-loop-command! [event-hub :refresh]
      (swap! ref-m dissoc id))))

(defn- %register-event
  [event-hub id fn k]
  (let [ref-m (k event-hub)]
    (with-issuing-event-go-loop-command! [event-hub :refresh]
      (swap! ref-m assoc id (make-chan-fun fn)))))

(defn register-tx-event
