# # # patch "cmd_db.cc" # from [2d1510b878cf4ae05f3474e5f3352583169a6474] # to [abc0b7cf0d2d9aa7b46991acbe007a4f3bd388e4] # # patch "cmd_list.cc" # from [625bb9c30ba36817c5969c053096dac4642d8305] # to [29ad489edc4c8d9292d012c4c9380b1d147d7c2d] # # patch "database.cc" # from [0cc2f1d01d5c2cf845bca7e98ba9e9aade305097] # to [d87ed94eb392b8109ce4fcb255d1030b92de3d24] # # patch "epoch.cc" # from [83f997c2d966b6385ce2e20d0d0f267c1c895e4a] # to [2cb502f82e6693f0d065db71c6c1ab9fb2e0df74] # # patch "netsync.cc" # from [8c01df0a8772cb5ddea060a6a3f286a6b8ad42d9] # to [2962967ca0dcefd85991ec040b70b9013c9dd643] # # patch "revision.cc" # from [b3d3647f4673ae7eb89ae2367057fa6aee0e719a] # to [7ade162706f7d85f1b66e51f034b6ad06e2883fb] # # patch "vocab.hh" # from [a71af670fcd0c3a4158fb2556dffa4c62d9499f4] # to [795b362dc61a675f612d99608c8722d1735b2ff0] # # patch "vocab_terms.hh" # from [f719298b85112812de89c837893fa860c8fa73ac] # to [cb250f9c6fc6803bf36f8e8d94a3c5978116a9ce] # ============================================================ --- cmd_db.cc 2d1510b878cf4ae05f3474e5f3352583169a6474 +++ cmd_db.cc abc0b7cf0d2d9aa7b46991acbe007a4f3bd388e4 @@ -309,10 +309,10 @@ CMD(db_set_epoch, "set_epoch", "", CMD_R if (args.size() != 2) throw usage(execid); - epoch_data ed(idx(args, 1)()); - N(ed.inner()().size() == constants::epochlen, + N(idx(args, 1)().size() == constants::epochlen, F("The epoch must be %s characters") % constants::epochlen); + epoch_data ed(decode_hexenc(idx(args, 1)())); database db(app); db.set_epoch(branch_name(idx(args, 0)()), ed); } ============================================================ --- cmd_list.cc 625bb9c30ba36817c5969c053096dac4642d8305 +++ cmd_list.cc 29ad489edc4c8d9292d012c4c9380b1d147d7c2d @@ -309,7 +309,7 @@ CMD(epochs, "epochs", "", CMD_REF(list), i = epochs.begin(); i != epochs.end(); ++i) { - cout << i->second << ' ' << i->first << '\n'; + cout << encode_hexenc(i->second.inner()()) << ' ' << i->first << '\n'; } } else @@ -320,7 +320,7 @@ CMD(epochs, "epochs", "", CMD_REF(list), { map::const_iterator j = epochs.find(branch_name((*i)())); N(j != epochs.end(), F("no epoch for branch %s") % *i); - cout << j->second << ' ' << j->first << '\n'; + cout << encode_hexenc(j->second.inner()()) << ' ' << j->first << '\n'; } } } ============================================================ --- database.cc 0cc2f1d01d5c2cf845bca7e98ba9e9aade305097 +++ database.cc d87ed94eb392b8109ce4fcb255d1030b92de3d24 @@ -3368,7 +3368,7 @@ database::get_epochs(mapexecute(query("INSERT OR REPLACE INTO branch_epochs VALUES(?, ?, ?)") % blob(eid.inner()()) % blob(branch()) ============================================================ --- epoch.cc 83f997c2d966b6385ce2e20d0d0f267c1c895e4a +++ epoch.cc 2cb502f82e6693f0d065db71c6c1ab9fb2e0df74 @@ -27,9 +27,7 @@ read_epoch(string const & in, raw_epoch = data(extract_substring(in, pos, constants::epochlen_bytes, "epoch, epoch data")); branch = branch_name(raw_branch); - hexenc tmp; - encode_hexenc(raw_epoch, tmp); - epoch = epoch_data(tmp); + epoch = epoch_data(raw_epoch); } void @@ -37,16 +35,14 @@ write_epoch(branch_name const & branch, string & out) { insert_variable_length_string(branch(), out); - data raw_epoch; - decode_hexenc(epoch.inner(), raw_epoch); - out += raw_epoch(); + out += epoch.inner()(); } void epoch_hash_code(branch_name const & branch, epoch_data const & epoch, epoch_id & eid) { - string tmp(branch() + ":" + epoch.inner()()); + string tmp(branch() + ":" + encode_hexenc(epoch.inner()())); data tdat(tmp); id out; calculate_ident(tdat, out); ============================================================ --- netsync.cc 8c01df0a8772cb5ddea060a6a3f286a6b8ad42d9 +++ netsync.cc 2962967ca0dcefd85991ec040b70b9013c9dd643 @@ -1924,14 +1924,16 @@ session::process_data_cmd(netcmd_item_ty branch_name branch; epoch_data epoch; read_epoch(dat, branch, epoch); - L(FL("received epoch %s for branch %s") % epoch % branch); + L(FL("received epoch %s for branch %s") + % encode_hexenc(epoch.inner()()) % branch); map epochs; project.db.get_epochs(epochs); map::const_iterator i; i = epochs.find(branch); if (i == epochs.end()) { - L(FL("branch %s has no epoch; setting epoch to %s") % branch % epoch); + L(FL("branch %s has no epoch; setting epoch to %s") + % branch % encode_hexenc(epoch.inner()())); project.db.set_epoch(branch, epoch); } else @@ -1952,8 +1954,10 @@ session::process_data_cmd(netcmd_item_ty (F("Mismatched epoch on branch %s." " Server has '%s', client has '%s'.") % branch - % (voice == server_voice ? i->second : epoch) - % (voice == server_voice ? epoch : i->second)).str()); + % encode_hexenc((voice == server_voice + ? i->second: epoch).inner()()) + % encode_hexenc((voice == server_voice + ? epoch : i->second).inner()())).str()); } } maybe_note_epochs_finished(); @@ -3180,7 +3184,7 @@ session::rebuild_merkle_trees(set epochs; project.db.get_epochs(epochs); - epoch_data epoch_zero(string(constants::epochlen, '0')); + epoch_data epoch_zero(string(constants::epochlen_bytes, '\x00')); for (set::const_iterator i = branchnames.begin(); i != branchnames.end(); ++i) { ============================================================ --- revision.cc b3d3647f4673ae7eb89ae2367057fa6aee0e719a +++ revision.cc 7ade162706f7d85f1b66e51f034b6ad06e2883fb @@ -933,10 +933,9 @@ void anc_graph::write_certs() { char buf[constants::epochlen_bytes]; Botan::Global_RNG::randomize(reinterpret_cast(buf), constants::epochlen_bytes); - hexenc hexdata; - encode_hexenc(data(string(buf, buf + constants::epochlen_bytes)), hexdata); - epoch_data new_epoch(hexdata); - L(FL("setting epoch for %s to %s") % *i % new_epoch); + epoch_data new_epoch(string(buf, buf + constants::epochlen_bytes)); + L(FL("setting epoch for %s to %s") + % *i % encode_hexenc(new_epoch.inner()())); db.set_epoch(branch_name(*i), new_epoch); } } ============================================================ --- vocab.hh a71af670fcd0c3a4158fb2556dffa4c62d9499f4 +++ vocab.hh 795b362dc61a675f612d99608c8722d1735b2ff0 @@ -83,7 +83,7 @@ typedef epoch epoch_id; typedef key key_id; typedef epoch epoch_id; -typedef epoch< hexenc > epoch_data; +typedef epoch< data > epoch_data; typedef revision< data > revision_data; typedef roster< data > roster_data; ============================================================ --- vocab_terms.hh f719298b85112812de89c837893fa860c8fa73ac +++ vocab_terms.hh cb250f9c6fc6803bf36f8e8d94a3c5978116a9ce @@ -84,11 +84,12 @@ EXTERN template class hexenc; EXTERN template class hexenc; -EXTERN template class epoch< hexenc >; EXTERN template class gzip; EXTERN template class base64< gzip >; +EXTERN template class epoch< data >; + EXTERN template class revision< data >; EXTERN template class roster< data >; EXTERN template class manifest< data >; @@ -132,8 +133,8 @@ EXTERN template std::ostream & operator< EXTERN template std::ostream & operator<< <>(std::ostream &, roster const &); EXTERN template std::ostream & operator<< <>(std::ostream &, manifest const &); -EXTERN template std::ostream & operator<< <>(std::ostream &, hexenc const &); -EXTERN template std::ostream & operator<< <>(std::ostream &, epoch< hexenc > const &); +EXTERN template std::ostream & operator<< <>(std::ostream &, hexenc const &); +EXTERN template std::ostream & operator<< <>(std::ostream &, epoch const &); EXTERN template std::ostream & operator<< <>(std::ostream &, gzip const &); EXTERN template std::ostream & operator<< <>(std::ostream &, base64< gzip > const &);