Optimized user pipes life time. (#26)

Optimized user-contract I/O pipes.
This commit is contained in:
Ravin Perera
2019-10-14 23:48:15 +05:30
committed by GitHub
parent 9ec9c9575d
commit dac43e857a
12 changed files with 240 additions and 135 deletions

View File

@@ -87,10 +87,12 @@ void user_session_handler::on_message(sock::socket_session *session, std::string
if (itr != usr::users.end())
{
// This is an authed user.
// Write the message to the user input pipe. SC will read from this pipe when it executes.
const util::contract_user &user = itr->second;
write(user.inpipe[1], message.data(), message.length());
std::cout << "User " << user.pubkeyb64 << " wrote " << message.length() << " bytes to contract input.\n";
usr::contract_user &user = itr->second;
//Hand over the bytes into user inbuffer.
user.inbuffer = std::move(message);
std::cout << "Collected " << user.inbuffer.length() << " bytes from user " << user.pubkeyb64 << std::endl;
return;
}
}