- static const char* str[] = { "INFO", "CREDIT", "LOAD",
- "CTRL_CLOSE", "DATA_CLOSE" };
- std::ostringstream oss;
- oss << str[type] << ": " << amount;
- return oss.str();
+ // compute message size
+ // arbitrary: 8 for type, and 8 for each double
+ switch (type) {
+ case CTRL:
+ size = opt::bookkeeping ? 24 : 16; // type + amount + (credit)?
+ break;
+ case DATA:
+ size = 16 + opt::comm_cost(amount); // type + amount + data size
+ break;
+ default:
+ size = 8; // type
+ break;
+ }