Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync master #500

Merged
merged 9 commits into from
Sep 23, 2021
7 changes: 3 additions & 4 deletions src/komodo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
}
else if ( func == 'N' || func == 'M' )
{
std::shared_ptr<komodo::event_notarized> evt = std::make_shared<komodo::event_notarized>(fp, ht, func == 'M');
std::shared_ptr<komodo::event_notarized> evt = std::make_shared<komodo::event_notarized>(fp, ht, dest, func == 'M');
komodo_eventadd_notarized(sp, symbol, ht, evt);
}
else if ( func == 'U' ) // deprecated
Expand Down Expand Up @@ -134,7 +134,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long
else if ( func == 'N' || func == 'M' )
{
std::shared_ptr<komodo::event_notarized> ntz =
std::make_shared<komodo::event_notarized>(filedata, fpos, datalen, ht, func == 'M');
std::make_shared<komodo::event_notarized>(filedata, fpos, datalen, ht, dest, func == 'M');
komodo_eventadd_notarized(sp, symbol, ht, ntz);
}
else if ( func == 'U' ) // deprecated
Expand Down Expand Up @@ -292,8 +292,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
{
if ( sp != 0 )
{
std::shared_ptr<komodo::event_notarized> evt = std::make_shared<komodo::event_notarized>(height);
memcpy(evt->dest, dest, sizeof(evt->dest)-1);
std::shared_ptr<komodo::event_notarized> evt = std::make_shared<komodo::event_notarized>(height, dest);
evt->blockhash = sp->NOTARIZED_HASH;
evt->desttxid = sp->NOTARIZED_DESTTXID;
evt->notarizedheight = sp->NOTARIZED_HEIGHT;
Expand Down
8 changes: 6 additions & 2 deletions src/komodo_structs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ std::ostream& operator<<(std::ostream& os, const event_rewind& in)
return os;
}

event_notarized::event_notarized(uint8_t *data, long &pos, long data_len, int32_t height, bool includeMoM)
event_notarized::event_notarized(uint8_t *data, long &pos, long data_len, int32_t height, const char* _dest, bool includeMoM)
: event(EVENT_NOTARIZED, height), MoMdepth(0)
{
strncpy(this->dest, _dest, sizeof(this->dest)-1);
this->dest[sizeof(this->dest)-1] = 0;
MoM.SetNull();
mem_read(this->notarizedheight, data, pos, data_len);
mem_read(this->blockhash, data, pos, data_len);
Expand All @@ -185,9 +187,11 @@ event_notarized::event_notarized(uint8_t *data, long &pos, long data_len, int32_
}
}

event_notarized::event_notarized(FILE* fp, int32_t height, bool includeMoM)
event_notarized::event_notarized(FILE* fp, int32_t height, const char* _dest, bool includeMoM)
: event(EVENT_NOTARIZED, height), MoMdepth(0)
{
strncpy(this->dest, _dest, sizeof(this->dest)-1);
this->dest[sizeof(this->dest)-1] = 0;
MoM.SetNull();
if ( fread(&notarizedheight,1,sizeof(notarizedheight),fp) != sizeof(notarizedheight) )
throw parse_error("Invalid notarization height");
Expand Down
12 changes: 8 additions & 4 deletions src/komodo_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,14 @@ std::ostream& operator<<(std::ostream& os, const event_rewind& in);

struct event_notarized : public event
{
event_notarized() : event(komodo_event_type::EVENT_NOTARIZED, 0), notarizedheight(0), MoMdepth(0) {}
event_notarized(int32_t ht) : event(EVENT_NOTARIZED, ht), notarizedheight(0), MoMdepth(0) {}
event_notarized(uint8_t* data, long &pos, long data_len, int32_t height, bool includeMoM = false);
event_notarized(FILE* fp, int32_t ht, bool includeMoM = false);
event_notarized() : event(komodo_event_type::EVENT_NOTARIZED, 0), notarizedheight(0), MoMdepth(0) {
memset(this->dest, 0, sizeof(this->dest));
}
event_notarized(int32_t ht, const char* _dest) : event(EVENT_NOTARIZED, ht), notarizedheight(0), MoMdepth(0) {
strncpy(this->dest, _dest, sizeof(this->dest)-1); this->dest[sizeof(this->dest)-1] = 0;
}
event_notarized(uint8_t* data, long &pos, long data_len, int32_t height, const char* _dest, bool includeMoM = false);
event_notarized(FILE* fp, int32_t ht, const char* _dest, bool includeMoM = false);
uint256 blockhash;
uint256 desttxid;
uint256 MoM;
Expand Down