 import CatenaCore
 import LoggerAPI
 
-/** The SQL agent coordinates participation in a dist*/
+/** The SQL agent coordinates participation in a distributed blockchain-based database. */
 public class SQLAgent {
 	let node: Node<SQLLedger>
 	private var counters: [PublicKey: SQLTransaction.CounterType] = [:]

		router.post("/api/*", middleware: mw)
		router.get("/api", handler: self.handleIndex)
		router.get("/api/counter/:hash", handler: self.handleGetCounter)
        router.post("/api/query", handler: self.handleQuery)

		// Debug APIs
		router.get("/debug/block/:hash", handler: self.handleGetBlock)

		router.get("/debug/journal", handler: self.handleGetJournal)
		router.get("/debug/pool", handler: self.handleGetPool)
		router.get("/debug/users", handler: self.handleGetUsers)

		router.all("/", middleware: StaticFileServer(path: "./Resources"))
	}

	private func handleQuery(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws {
		do {
			var data = Data(capacity: 1024)
			try _ = request.read(into: &data)
			let query = try JSONSerialization.jsonObject(with: data, options: [])

			// Parse the statement
			if let q = query as? [String: Any], let sql = q["sql"] as? String {
				let rawStatement = try SQLStatement(sql)

				// Did the client send parameters to fill in?
				let suppliedParameters = (q["parameters"] as? [String: Any]) ?? [:]
