Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #632 from GolosChain/527-genesis-generate-names
Better account_names generation + split genesis-create #527
- Loading branch information
Showing
11 changed files
with
434 additions
and
402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
libraries/chain/include/cyberway/genesis/genesis_generate_name.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
#include <eosio/chain/name.hpp> | ||
#include <fc/crypto/sha1.hpp> | ||
|
||
namespace cyberway { namespace genesis { | ||
|
||
inline eosio::chain::name generate_name(std::string txt) { | ||
auto hash = fc::sha1::hash(txt); // can implement something faster like MurmurHash3, but sha1 looks enough | ||
uint64_t data = ((uint64_t*)(hash.data()))[0]; | ||
uint64_t r = 0; | ||
// names are base32 and 0 maps to '.' symbol. to avoid dots transform to base31 and increment each symbol | ||
for (int i = 0; i < 12; i++) { | ||
auto quot = data / 31; // pair with % so compiler can produce 1 op for both div/mod | ||
auto rem = data % 31; | ||
data = quot; | ||
r |= (rem + 1) << (64 - 5 * (i + 1)); | ||
} | ||
return eosio::chain::name(r); | ||
} | ||
|
||
}} // cyberway::genesis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
#include <eosio/chain/name.hpp> | ||
|
||
|
||
namespace cyberway { namespace genesis { | ||
|
||
static constexpr uint64_t gls_issuer_account_name = N(gls.issuer); | ||
static constexpr uint64_t gls_ctrl_account_name = N(gls.ctrl); | ||
static constexpr uint64_t gls_vest_account_name = N(gls.vesting); | ||
static constexpr uint64_t gls_post_account_name = N(gls.publish); | ||
static constexpr uint64_t gls_social_account_name = N(gls.social); | ||
static constexpr uint64_t gls_charge_account_name = N(gls.charge); | ||
constexpr auto notify_account_name = gls_ctrl_account_name; | ||
|
||
constexpr auto GBG = SY(3,GBG); | ||
constexpr auto GLS = SY(3,GOLOS); | ||
constexpr auto GESTS = SY(6,GESTS); | ||
constexpr auto VESTS = SY(6,GOLOS); // Golos dApp vesting | ||
constexpr auto posting_auth_name = "posting"; | ||
constexpr auto golos_domain_name = "golos"; | ||
|
||
constexpr auto withdraw_interval_seconds = 60*60*24*7; | ||
constexpr auto withdraw_intervals = 13; | ||
|
||
constexpr int64_t system_max_supply = 1'000'000'000ll * 10000; // 4 digits precision | ||
constexpr int64_t golos_max_supply = 1'000'000'000ll * 1000; // 3 digits precision | ||
|
||
constexpr int fixp_fract_digits = 12; | ||
|
||
|
||
}} // cyberway::genesis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.