未验证 提交 ff478bbd 编写于 作者: D Daniel Larimer 提交者: GitHub

Merge pull request #3199 from EOSIO/3119

Adjust voting weight
...@@ -122,7 +122,7 @@ namespace eosiosystem { ...@@ -122,7 +122,7 @@ namespace eosiosystem {
double stake2vote( int64_t staked ) { double stake2vote( int64_t staked ) {
/// TODO subtract 2080 brings the large numbers closer to this decade /// TODO subtract 2080 brings the large numbers closer to this decade
double weight = int64_t( (now() / (seconds_per_day * 7)) ) / double( 52 ); double weight = int64_t( (now() - (block_timestamp::block_timestamp_epoch / 1000)) / (seconds_per_day * 7) ) / double( 52 );
return double(staked) * std::pow( 2, weight ); return double(staked) * std::pow( 2, weight );
} }
/** /**
......
...@@ -156,11 +156,12 @@ namespace eosio { ...@@ -156,11 +156,12 @@ namespace eosio {
bool operator ==( const block_timestamp& t )const { return slot == t.slot; } bool operator ==( const block_timestamp& t )const { return slot == t.slot; }
bool operator !=( const block_timestamp& t )const { return slot != t.slot; } bool operator !=( const block_timestamp& t )const { return slot != t.slot; }
uint32_t slot; uint32_t slot;
static constexpr int32_t block_interval_ms = 500;
static constexpr int64_t block_timestamp_epoch = 946684800000ll; // epoch is year 2000
EOSLIB_SERIALIZE( block_timestamp, (slot) ) EOSLIB_SERIALIZE( block_timestamp, (slot) )
private: private:
static constexpr int32_t block_interval_ms = 500;
static constexpr int64_t block_timestamp_epoch = 946684800000ll; // epoch is year 2000
void set_time_point(const time_point& t) { void set_time_point(const time_point& t) {
int64_t micro_since_epoch = t.time_since_epoch().count(); int64_t micro_since_epoch = t.time_since_epoch().count();
......
...@@ -353,7 +353,7 @@ public: ...@@ -353,7 +353,7 @@ public:
double stake2votes( asset stake ) { double stake2votes( asset stake ) {
auto now = control->pending_block_time().time_since_epoch().count() / 1000000; auto now = control->pending_block_time().time_since_epoch().count() / 1000000;
return stake.amount * pow(2, int64_t(now/ (86400 * 7))/ double(52) ); // 52 week periods (i.e. ~years) return stake.amount * pow(2, int64_t((now - (config::block_timestamp_epoch / 1000)) / (86400 * 7))/ double(52) ); // 52 week periods (i.e. ~years)
} }
double stake2votes( const string& s ) { double stake2votes( const string& s ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册