<commit_before>#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <time.h>
#include <memory>

#include "derecho/derecho_group.h"
#include "derecho/derecho_caller.h"
#include "derecho/managed_group.h"
#include "derecho/view.h"
#include "block_size.h"
#include "rdmc/util.h"

using std::vector;
using std::map;
using std::string;
using std::cout;
using std::endl;
using namespace std;
using namespace mutils;

using derecho::DerechoGroup;
using derecho::DerechoSST;

int count = 0;

struct test1_str{
    int state;
    int read_state() {
        cout << "Returning state, it is: " << state << endl;
        return state;
    }
    bool change_state(int new_state) {
        cout << "Previous state was: " << state << endl;
        state = new_state;
        cout << "Current state is: " << state << endl;
        return true;
    }

    template <typename Dispatcher>
    auto register_functions(Dispatcher &d, std::unique_ptr<test1_str> *ptr) {
      assert(this == ptr->get());
        return d.register_functions(ptr, &test1_str::read_state,
                                    &test1_str::change_state);
    }
};

void output_result(auto& rmap) {
    cout << "Obtained a reply map" << endl;
    for(auto it = rmap.begin(); it != rmap.end(); ++it) {
        try {
            cout << "Reply from node " << it->first << ": " << it->second.get()
                 << endl;
        } catch(const std::exception &e) {
            cout << e.what() << endl;
        }
    }
}

int main(int argc, char *argv[]) {
    srand(time(NULL));

    uint32_t leader_id = 0;
    string leader_ip = "192.168.127.12";
    uint32_t my_id;
    string my_ip;
    cin >> my_id;
    cin >> my_ip;
    
    long long unsigned int max_msg_size = 100;
    long long unsigned int block_size = get_block_size(max_msg_size);
    // int num_messages = 10;

    auto stability_callback = [](int sender_id, long long int index, char *buf,
                                 long long int msg_size) {};

    Dispatcher<test1_str> dispatchers(my_id, std::make_tuple());

    derecho::DerechoParams derecho_params{max_msg_size, block_size};
    derecho::ManagedGroup<decltype(dispatchers)>* managed_group;

    if(my_id == 0) {
        managed_group = new derecho::ManagedGroup<decltype(dispatchers)>(
            my_ip, std::move(dispatchers), {stability_callback, {}},<commit_msg>derecho_caller_test works<commit_after>#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <time.h>
#include <memory>

#include "derecho/derecho_group.h"
#include "derecho/derecho_caller.h"
#include "derecho/managed_group.h"
#include "derecho/view.h"
#include "block_size.h"
#include "rdmc/util.h"

using std::vector;
using std::map;
using std::string;
using std::cout;
using std::endl;
using namespace std;
using namespace mutils;

using derecho::DerechoGroup;
using derecho::DerechoSST;

int count = 0;

struct test1_str{
    int state;
    int read_state() {
        cout << "Returning state, it is: " << state << endl;
        return state;
    }
    bool change_state(int new_state) {
        cout << "Previous state was: " << state << endl;
        state = new_state;
        cout << "Current state is: " << state << endl;
        return true;
    }

    template <typename Dispatcher>
    auto register_functions(Dispatcher &d, std::unique_ptr<test1_str> *ptr) {
      assert(this == ptr->get());
        return d.register_functions(ptr, &test1_str::read_state,
                                    &test1_str::change_state);
    }
};

void output_result(auto& rmap) {
    cout << "Obtained a reply map" << endl;
    for(auto it = rmap.begin(); it != rmap.end(); ++it) {
        try {
            cout << "Reply from node " << it->first << ": " << it->second.get()
                 << endl;
        } catch(const std::exception &e) {
            cout << e.what() << endl;
        }
    }
}

int main(int argc, char *argv[]) {
    srand(time(NULL));

    uint32_t leader_id = 0;
    string leader_ip;
    uint32_t my_id;
    string my_ip;
    cout << "Enter my id" << endl;
    cin >> my_id;
    cout << "Enter my ip" << endl;
    cin >> my_ip;
    cout << "Enter leader ip" << endl;
    cin >> leader_ip;
    
    long long unsigned int max_msg_size = 100;
    long long unsigned int block_size = get_block_size(max_msg_size);
    // int num_messages = 10;

    auto stability_callback = [](int sender_id, long long int index, char *buf,
                                 long long int msg_size) {};

    Dispatcher<test1_str> dispatchers(my_id, std::make_tuple());

    derecho::DerechoParams derecho_params{max_msg_size, block_size};
    derecho::ManagedGroup<decltype(dispatchers)>* managed_group;

    if(my_id == 0) {
        managed_group = new derecho::ManagedGroup<decltype(dispatchers)>(
            my_ip, std::move(dispatchers), {stability_callback, {}},
{'fraction_non_alphanumeric': 0.13746409519901517, 'fraction_numerical': 0.009232663110381617, 'mean_word_length': 2.8782816229116945, 'pattern_counts': {'":': 2, '<': 109, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3302596', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1606, 'n_words': 395}