#include #include "../include/Database.hpp" #include "../include/Group.hpp" #include "../include/LocalUser.hpp" #include #include using namespace std; using namespace chrono_literals; using namespace odhtdb; int main() { LocalUser *localUser = LocalUser::create(Signature::KeyPair(), "dec05eba"); std::string publicKeyStr = localUser->getPublicKey().toString(); printf("Local user public key: %s\n", publicKeyStr.c_str()); std::string privateKeyStr = localUser->getPrivateKey().toString(); printf("Local user private key: %s\n", privateKeyStr.c_str()); /* char hex_ed_pk[65]; unsigned char seed[crypto_sign_ed25519_SEEDBYTES]; unsigned char ed25519_skpk[crypto_sign_ed25519_SECRETKEYBYTES]; unsigned char ed25519_pk[crypto_sign_ed25519_PUBLICKEYBYTES]; crypto_sign_ed25519_sk_to_seed(seed, ed25519_skpk); crypto_sign_ed25519_seed_keypair(ed25519_pk, ed25519_skpk, seed); sodium_bin2hex(hex_ed_pk, 65, ed25519_pk, 32); printf("public key: %s\n", hex_ed_pk); */ // TODO: For tests, dont run against bootstrap.ring.cx. // Run against a bootstrap node made only for testing which doesn't persist added data. Database database("bootstrap.ring.cx", 4222, "storage"); database.seed(); Group group("admin"); group.addUser(localUser); database.create("galax.channel.latenight.chat", &group); //const char *data = "hello, world!"; //database.add("galax.channel.latenight.chat", DataView{ (void*)data, strlen(data) }); database.commit(); auto start = chrono::high_resolution_clock::now(); while(chrono::high_resolution_clock::now() - start < 5s) { this_thread::sleep_for(10ms); } return 0; }