Skip to content

Commit

Permalink
Merge pull request #500 from KomodoPlatform/beta
Browse files Browse the repository at this point in the history
sync master
  • Loading branch information
ca333 authored Sep 23, 2021
2 parents 7df102f + 0af3582 commit d7edae2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
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

0 comments on commit d7edae2

Please sign in to comment.