YPC  0.2.0
db.h
1 #pragma once
2 #include "ypc/core/byte.h"
3 #include "ypc/core/db.h"
4 #include <ff/sql.h>
5 #include <memory>
6 
7 define_column(request_hash, index, ypc::hex_bytes, "request_hash");
8 define_column(encrypted_skey, column, ypc::hex_bytes, "encrypted_skey");
9 define_column(encrypted_input, column, ypc::hex_bytes, "encrypted_input");
10 define_column(provider_pkey, column, ypc::hex_bytes, "provider_pkey");
11 define_column(analyzer_pkey, column, ypc::hex_bytes, "analyzer_pkey");
12 define_column(enclave_hash, column, ypc::hex_bytes, "program_enclave_hash");
13 define_column(forward_sig, column, ypc::hex_bytes, "forward_sig");
14 
15 define_column(status, column, uint64_t, "status");
16 define_column(encrypted_result, column, ypc::hex_bytes, "encrypted_result");
17 define_column(result_signature, column, ypc::hex_bytes, "result_signature");
18 define_column(cost_signature, column, ypc::hex_bytes, "cost_signature");
19 define_column(data_hash, column, ypc::hex_bytes, "data_hash");
20 
21 namespace ff {
22 namespace sql {
23 template <class STMT> struct mysql_bind_setter<STMT, ypc::hex_bytes> {
24  static void bind(STMT stmt, int index, const ypc::hex_bytes &value) {
25  stmt->setString(index,
26  std::string((const char *)value.data(), value.size()));
27  }
28 };
29 
30 template <> struct mysql_rs_getter<ypc::hex_bytes> {
31  template <typename RST>
32  static ypc::hex_bytes get(RST r, const std::string &name) {
33  std::string str = r->getString(name);
34  return ypc::hex_bytes(str.c_str(), str.size());
35  }
36 };
37 } // namespace sql
38 } // namespace ff
39 /*
40 define_column(request_hash, index, std::string, "request_hash");
41 define_column(encrypted_skey, column, std::string, "encrypted_skey");
42 define_column(encrypted_input, column, std::string, "encrypted_input");
43 define_column(provider_pkey, column, std::string, "provider_pkey");
44 define_column(analyzer_pkey, column, std::string, "analyzer_pkey");
45 define_column(enclave_hash, column, std::string, "program_enclave_hash");
46 define_column(forward_sig, column, std::string, "forward_sig");
47 
48 define_column(status, column, uint64_t, "status");
49 define_column(encrypted_result, column, std::string, "encrypted_result");
50 define_column(result_signature, column, std::string, "result_signature");
51 define_column(data_hash, column, std::string, "data_hash");
52 */
53 
54 namespace toolkit {
55 namespace analyzer {
56 
58  constexpr static const char *table_name = "RequestData";
59 };
60 
61 typedef ::ff::sql::table<::ff::sql::mysql<::ff::sql::cppconn>,
62  request_data_table_desc, request_hash, encrypted_skey,
63  encrypted_input, provider_pkey, analyzer_pkey,
64  enclave_hash, forward_sig, status, encrypted_result,
65  result_signature, cost_signature, data_hash>
66  request_data_table;
67 typedef typename request_data_table::row_type request_data_item_t;
68 
69 class request_db : public ypc::db_base {
70 public:
71  request_db(const std::string &url, const std::string &usrname,
72  const std::string &passwd, const std::string &dbname);
73  virtual void create_tables();
74  virtual void clear_tables();
75 };
76 } // namespace ypcd
77 } // namespace toolkit
78 
ypc::db_base
Definition: db.h:9
toolkit::analyzer::request_db
Definition: db.h:69
toolkit::analyzer::request_data_table_desc
Definition: db.h:57
byte.h
ypc::utc::bytes
Definition: bytes.h:143