Config patch change detection. (#211)

* Applying patch file changes to hpcore runtime after patch file change detection.
* Removing unl sync functionality.
* Removing subjecting unl changeset to consensus.
This commit is contained in:
Savinda Senevirathne
2021-01-06 20:02:14 +05:30
committed by GitHub
parent c87ae6693d
commit bed8205ca8
22 changed files with 90 additions and 1033 deletions

View File

@@ -231,14 +231,9 @@ namespace msg::fbuf::p2pmsg
p.nonce = flatbuff_bytes_to_sv(msg.nonce());
p.stage = msg.stage();
p.lcl = flatbuff_bytes_to_sv(lcl);
p.unl_hash = flatbuff_bytes_to_sv(msg.unl_hash());
p.state_hash = flatbuff_bytes_to_sv(msg.state_hash());
p.patch_hash = flatbuff_bytes_to_sv(msg.patch_hash());
const auto unl_changeset = msg.unl_changeset();
p.unl_changeset.additions = flatbuf_bytearrayvector_to_stringlist(unl_changeset->additions());
p.unl_changeset.removals = flatbuf_bytearrayvector_to_stringlist(unl_changeset->removals());
if (msg.users())
p.users = flatbuf_bytearrayvector_to_stringlist(msg.users());
@@ -378,11 +373,6 @@ namespace msg::fbuf::p2pmsg
// todo:get a average propsal message size and allocate content builder based on that.
flatbuffers::FlatBufferBuilder builder(1024);
const flatbuffers::Offset<Unl_Changeset> unl_changeset = CreateUnl_Changeset(
builder,
stringlist_to_flatbuf_bytearrayvector(builder, p.unl_changeset.additions),
stringlist_to_flatbuf_bytearrayvector(builder, p.unl_changeset.removals));
const flatbuffers::Offset<Proposal_Message> proposal =
CreateProposal_Message(
builder,
@@ -394,9 +384,7 @@ namespace msg::fbuf::p2pmsg
sv_to_flatbuff_bytes(builder, p.output_hash),
sv_to_flatbuff_bytes(builder, p.output_sig),
hash_to_flatbuff_bytes(builder, p.state_hash),
hash_to_flatbuff_bytes(builder, p.patch_hash),
sv_to_flatbuff_bytes(builder, p.unl_hash),
unl_changeset);
hash_to_flatbuff_bytes(builder, p.patch_hash));
const flatbuffers::Offset<Content> message = CreateContent(builder, Message_Proposal_Message, proposal.Union());
builder.Finish(message); // Finished building message content to get serialised content.
@@ -691,79 +679,6 @@ namespace msg::fbuf::p2pmsg
create_containermsg_from_content(container_builder, builder, lcl, false);
}
/**
* Create unl request message from the given unl sync request struct.
* @param container_builder Flatbuffer builder for the container message.
* @param unl_sync_message The Unl sync request struct to be placed in the container message.
*/
void create_msg_from_unl_sync_request(flatbuffers::FlatBufferBuilder &container_builder, const p2p::unl_sync_request &unl_sync_message)
{
flatbuffers::FlatBufferBuilder builder(1024);
flatbuffers::Offset<Unl_Request_Message> unl_req_msg =
CreateUnl_Request_Message(
builder,
sv_to_flatbuff_bytes(builder, unl_sync_message.required_unl));
flatbuffers::Offset<Content> message = CreateContent(builder, Message_Unl_Request_Message, unl_req_msg.Union());
builder.Finish(message); // Finished building message content to get serialised content.
// Now that we have built the content message,
// we need to place it inside a container message.
create_containermsg_from_content(container_builder, builder, {}, false);
}
/**
* Creates a unl sync request struct from the given unl request message.
* @param unl_req_message Flatbuffer unl request message received from the peer.
* @return A unl sync request struct representing the message.
*/
const p2p::unl_sync_request create_unl_sync_request_from_msg(const Unl_Request_Message &unl_req_message)
{
p2p::unl_sync_request unl_sync;
unl_sync.required_unl = flatbuff_bytes_to_sv(unl_req_message.required_unl());
return unl_sync;
}
/**
* Create unl response message from the given unl sync response struct.
* @param container_builder Flatbuffer builder for the container message.
* @param unl_response The unl sync response struct to be placed in the container message.
*/
void create_msg_from_unl_sync_response(flatbuffers::FlatBufferBuilder &container_builder, const p2p::unl_sync_response &unl_response)
{
flatbuffers::FlatBufferBuilder builder(1024);
flatbuffers::Offset<Unl_Response_Message> unl_res_msg =
CreateUnl_Response_Message(
builder,
sv_to_flatbuff_bytes(builder, unl_response.requester_unl),
stringlist_to_flatbuf_bytearrayvector(builder, unl_response.unl_list));
flatbuffers::Offset<Content> message = CreateContent(builder, Message_Unl_Response_Message, unl_res_msg.Union());
builder.Finish(message); // Finished building message content to get serialised content.
// Now that we have built the content message,
// we need to place it inside a container message.
create_containermsg_from_content(container_builder, builder, {}, false);
}
/**
* Creates a unl sync response struct from the given unl response message.
* @param unl_response_message Flatbuffer unl response message received from the peer.
* @return A unl sync response struct representing the message.
*/
const p2p::unl_sync_response create_unl_sync_response_from_msg(const Unl_Response_Message &unl_response_message)
{
p2p::unl_sync_response unl_sync_response;
unl_sync_response.requester_unl = flatbuff_bytes_to_sv(unl_response_message.requester_unl());
unl_sync_response.unl_list = flatbuf_bytearrayvector_to_stringlist(unl_response_message.unl_list());
return unl_sync_response;
}
/**
* Creates a Flatbuffer container message from the given Content message.
* @param container_builder The Flatbuffer builder to which the final container message should be written to.