User inputs round limit. (#240)

This commit is contained in:
Ravin Perera
2021-02-14 20:19:53 +05:30
committed by GitHub
parent 067883b778
commit 033b5fa7bc
13 changed files with 234 additions and 160 deletions

View File

@@ -81,8 +81,10 @@ namespace msg::fbuf::ledger
map.reserve(fbvec->size());
for (auto el : *fbvec)
{
usr::raw_user_input raw_user_input(flatbuff_bytes_to_sv(el->pubkey()), flatbuff_bytes_to_sv(el->input()));
map.emplace(flatbuff_bytes_to_sv(el->hash()), raw_user_input);
map.emplace(flatbuff_bytes_to_sv(el->hash()),
usr::raw_user_input{
std::string(flatbuff_bytes_to_sv(el->pubkey())),
std::string(flatbuff_bytes_to_sv(el->input()))});
}
return map;
}

View File

@@ -730,21 +730,21 @@ namespace msg::fbuf::p2pmsg
//---Conversion helpers from flatbuffers data types to std data types---//
const std::unordered_map<std::string, std::list<usr::user_input>>
const std::unordered_map<std::string, std::list<usr::submitted_user_input>>
flatbuf_user_input_group_to_user_input_map(const flatbuffers::Vector<flatbuffers::Offset<UserInputGroup>> *fbvec)
{
std::unordered_map<std::string, std::list<usr::user_input>> map;
std::unordered_map<std::string, std::list<usr::submitted_user_input>> map;
map.reserve(fbvec->size());
for (const UserInputGroup *group : *fbvec)
{
std::list<usr::user_input> user_inputs_list;
std::list<usr::submitted_user_input> user_inputs_list;
for (const auto msg : *group->messages())
{
user_inputs_list.push_back(usr::user_input(
flatbuff_bytes_to_sv(msg->input_container()),
flatbuff_bytes_to_sv(msg->signature()),
static_cast<util::PROTOCOL>(msg->protocol())));
user_inputs_list.push_back(usr::submitted_user_input{
std::string(flatbuff_bytes_to_sv(msg->input_container())),
std::string(flatbuff_bytes_to_sv(msg->signature())),
static_cast<util::PROTOCOL>(msg->protocol())});
}
map.emplace(flatbuff_bytes_to_sv(group->pubkey()), std::move(user_inputs_list));
@@ -756,14 +756,14 @@ namespace msg::fbuf::p2pmsg
//---These are used in constructing Flatbuffer messages using builders---//
const flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<UserInputGroup>>>
user_input_map_to_flatbuf_user_input_group(flatbuffers::FlatBufferBuilder &builder, const std::unordered_map<std::string, std::list<usr::user_input>> &map)
user_input_map_to_flatbuf_user_input_group(flatbuffers::FlatBufferBuilder &builder, const std::unordered_map<std::string, std::list<usr::submitted_user_input>> &map)
{
std::vector<flatbuffers::Offset<UserInputGroup>> fbvec;
fbvec.reserve(map.size());
for (const auto &[pubkey, msglist] : map)
{
std::vector<flatbuffers::Offset<UserInput>> fbmsgsvec;
for (const usr::user_input &msg : msglist)
for (const usr::submitted_user_input &msg : msglist)
{
fbmsgsvec.push_back(CreateUserInput(
builder,
@@ -787,7 +787,7 @@ namespace msg::fbuf::p2pmsg
for (const HistoryLedgerBlockPair *pair : *fbvec)
{
std::list<usr::user_input> msglist;
std::list<usr::submitted_user_input> msglist;
p2p::history_ledger_block ledger;

View File

@@ -80,13 +80,13 @@ namespace msg::fbuf::p2pmsg
//---Conversion helpers from flatbuffers data types to std data types---//
const std::unordered_map<std::string, std::list<usr::user_input>>
const std::unordered_map<std::string, std::list<usr::submitted_user_input>>
flatbuf_user_input_group_to_user_input_map(const flatbuffers::Vector<flatbuffers::Offset<UserInputGroup>> *fbvec);
//---Conversion helpers from std data types to flatbuffers data types---//
const flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<UserInputGroup>>>
user_input_map_to_flatbuf_user_input_group(flatbuffers::FlatBufferBuilder &builder, const std::unordered_map<std::string, std::list<usr::user_input>> &map);
user_input_map_to_flatbuf_user_input_group(flatbuffers::FlatBufferBuilder &builder, const std::unordered_map<std::string, std::list<usr::submitted_user_input>> &map);
const std::map<uint64_t, const p2p::history_ledger_block>
flatbuf_historyledgermap_to_historyledgermap(const flatbuffers::Vector<flatbuffers::Offset<HistoryLedgerBlockPair>> *fbvec);

View File

@@ -58,6 +58,8 @@ namespace msg::usrmsg
constexpr const char *REASON_MAX_LEDGER_EXPIRED = "max_ledger_expired";
constexpr const char *REASON_NONCE_EXPIRED = "nonce_expired";
constexpr const char *REASON_ALREADY_SUBMITTED = "already_submitted";
constexpr const char *REASON_NONCE_OVERFLOW = "nonce_overflow";
constexpr const char *REASON_ROUND_INPUTS_OVERFLOW = "round_inputs_overflow";
} // namespace msg::usrmsg