Skip to content

Commit

Permalink
Merge pull request #49 from IOTA-Ledger/hotfix/conversion
Browse files Browse the repository at this point in the history
Improve binary<>ternary conversion
  • Loading branch information
Wollac authored Dec 30, 2018
2 parents 62990c4 + bc0fa66 commit 77648f6
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 170 deletions.
8 changes: 4 additions & 4 deletions src/iota/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ static void create_bundle_bytes(int64_t value, const char *tag,
{
trit_t bundle_essence_trits[243] = {0};

int64_to_trits(value, bundle_essence_trits, 81);
s64_to_trits(value, bundle_essence_trits, 81);
chars_to_trits(tag, bundle_essence_trits + 81, 27);
int64_to_trits(timestamp, bundle_essence_trits + 162, 27);
int64_to_trits(current_tx_index, bundle_essence_trits + 189, 27);
int64_to_trits(last_tx_index, bundle_essence_trits + 216, 27);
u32_to_trits(timestamp, bundle_essence_trits + 162, 27);
u32_to_trits(current_tx_index, bundle_essence_trits + 189, 27);
u32_to_trits(last_tx_index, bundle_essence_trits + 216, 27);

// now we have exactly one chunk of 243 trits
trits_to_bytes(bundle_essence_trits, bytes);
Expand Down
Loading

0 comments on commit 77648f6

Please sign in to comment.