Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
241c738f
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
241c738f
编写于
7月 04, 2017
作者:
N
Nathan Hourt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix setproducer regression
上级
6b5d0570
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
47 deletion
+42
-47
libraries/chain/include/eos/chain/chain_controller.hpp
libraries/chain/include/eos/chain/chain_controller.hpp
+2
-1
libraries/native_contract/staked_balance_contract.cpp
libraries/native_contract/staked_balance_contract.cpp
+27
-43
tests/common/macro_support.hpp
tests/common/macro_support.hpp
+13
-3
未找到文件。
libraries/chain/include/eos/chain/chain_controller.hpp
浏览文件 @
241c738f
...
...
@@ -156,7 +156,8 @@ namespace eos { namespace chain {
auto
on_exit
=
fc
::
make_scoped_exit
(
[
&
](){
for
(
const
auto
&
t
:
old_pending
)
{
try
{
push_transaction
(
t
);
if
(
!
is_known_transaction
(
t
.
id
()))
push_transaction
(
t
);
}
catch
(
...
){}
}
});
...
...
libraries/native_contract/staked_balance_contract.cpp
浏览文件 @
241c738f
...
...
@@ -81,58 +81,42 @@ void apply_staked_claim(apply_context& context) {
}
void
validate_staked_setproducer
(
message_validate_context
&
context
)
{
auto
cre
ate
=
context
.
msg
.
as
<
types
::
setproducer
>
();
EOS_ASSERT
(
cre
ate
.
name
.
good
(),
message_validate_exception
,
"Producer owner name cannot be empty"
);
auto
upd
ate
=
context
.
msg
.
as
<
types
::
setproducer
>
();
EOS_ASSERT
(
upd
ate
.
name
.
good
(),
message_validate_exception
,
"Producer owner name cannot be empty"
);
}
void
precondition_staked_setproducer
(
precondition_validate_context
&
context
)
{
auto
cre
ate
=
context
.
msg
.
as
<
types
::
setproducer
>
();
auto
upd
ate
=
context
.
msg
.
as
<
types
::
setproducer
>
();
const
auto
&
db
=
context
.
db
;
auto
producer
=
db
.
find
<
producer_object
,
by_owner
>
(
create
.
name
);
EOS_ASSERT
(
producer
==
nullptr
,
message_precondition_exception
,
"Account ${name} already has a block producer"
,
(
"name"
,
create
.
name
));
auto
producer
=
db
.
find
<
producer_object
,
by_owner
>
(
update
.
name
);
if
(
producer
)
EOS_ASSERT
(
producer
->
signing_key
!=
update
.
key
||
producer
->
configuration
!=
update
.
configuration
,
message_validate_exception
,
"Producer's new settings may not be identical to old settings"
);
}
void
apply_staked_setproducer
(
apply_context
&
context
)
{
auto
create
=
context
.
msg
.
as
<
types
::
setproducer
>
();
auto
&
db
=
context
.
mutable_db
;
db
.
create
<
producer_object
>
([
&
create
](
producer_object
&
p
)
{
p
.
owner
=
create
.
name
;
p
.
signing_key
=
create
.
key
;
p
.
configuration
=
create
.
configuration
;
});
auto
raceTime
=
ProducerScheduleObject
::
get
(
db
).
currentRaceTime
;
db
.
create
<
ProducerVotesObject
>
([
&
create
,
&
raceTime
](
ProducerVotesObject
&
pvo
)
{
pvo
.
ownerName
=
create
.
name
;
pvo
.
startNewRaceLap
(
raceTime
);
});
}
/*
void UpdateProducer::validate(message_validate_context& context) {
auto update = context.msg.as<types::UpdateProducer>();
EOS_ASSERT(update.name.good(), message_validate_exception, "Producer owner name cannot be empty");
}
void UpdateProducer::validate_preconditions(precondition_validate_context& context) {
const auto& db = context.db;
auto update = context.msg.as<types::UpdateProducer>();
const auto& producer = db.get<producer_object, by_owner>(update.name);
EOS_ASSERT(producer.signing_key != update.newKey || producer.configuration != update.configuration,
message_validate_exception, "Producer's new settings may not be identical to old settings");
}
void UpdateProducer::apply(apply_context& context) {
auto
update
=
context
.
msg
.
as
<
types
::
setproducer
>
();
auto
&
db
=
context
.
mutable_db
;
auto update = context.msg.as<types::UpdateProducer>();
const auto& producer = db.get<producer_object, by_owner>(update.name);
db.modify(producer, [&update](producer_object& p) {
p.signing_key = update.newKey;
p.configuration = update.configuration;
});
auto
producer
=
db
.
find
<
producer_object
,
by_owner
>
(
update
.
name
);
if
(
producer
)
db
.
modify
(
*
producer
,
[
&
update
](
producer_object
&
p
)
{
p
.
signing_key
=
update
.
key
;
p
.
configuration
=
update
.
configuration
;
});
else
{
db
.
create
<
producer_object
>
([
&
update
](
producer_object
&
p
)
{
p
.
owner
=
update
.
name
;
p
.
signing_key
=
update
.
key
;
p
.
configuration
=
update
.
configuration
;
});
auto
raceTime
=
ProducerScheduleObject
::
get
(
db
).
currentRaceTime
;
db
.
create
<
ProducerVotesObject
>
([
name
=
update
.
name
,
raceTime
](
ProducerVotesObject
&
pvo
)
{
pvo
.
ownerName
=
name
;
pvo
.
startNewRaceLap
(
raceTime
);
});
}
}
*/
void
validate_staked_okproducer
(
message_validate_context
&
context
)
{
auto
approve
=
context
.
msg
.
as
<
types
::
okproducer
>
();
...
...
tests/common/macro_support.hpp
浏览文件 @
241c738f
...
...
@@ -8,16 +8,18 @@
block_log name ## _log(get_temp_dir() / "blocklog"); \
fork_database name ## _fdb; \
native_contract::native_contract_chain_initializer name ## _initializer(genesis_state()); \
testing_blockchain name(name ## _db, name ## _fdb, name ## _log, name ## _initializer, *this);
testing_blockchain name(name ## _db, name ## _fdb, name ## _log, name ## _initializer, *this); \
BOOST_TEST_CHECKPOINT("Created blockchain " << #name);
#define MKCHAIN2(name, id) \
chainbase::database name ## _db(get_temp_dir(#id), chainbase::database::read_write, TEST_DB_SIZE); \
block_log name ## _log(get_temp_dir(#id) / "blocklog"); \
fork_database name ## _fdb; \
native_contract::native_contract_chain_initializer name ## _initializer(genesis_state()); \
testing_blockchain name(name ## _db, name ## _fdb, name ## _log, name ## _initializer, *this);
testing_blockchain name(name ## _db, name ## _fdb, name ## _log, name ## _initializer, *this); \
BOOST_TEST_CHECKPOINT("Created blockchain " << #name);
#define MKCHAINS_MACRO(x, y, name) Make_Blockchain(name)
#define MKNET1(name) testing_network name;
#define MKNET1(name) testing_network name;
BOOST_TEST_CHECKPOINT("Created testnet " << #name);
#define MKNET2_MACRO(x, name, chain) name.connect_blockchain(chain);
#define MKNET2(name, ...) MKNET1(name) BOOST_PP_SEQ_FOR_EACH(MKNET2_MACRO, name, __VA_ARGS__)
...
...
@@ -31,6 +33,7 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Created account " << #name); \
}
#define MKACCT2(chain, name) \
Make_Key(name) \
...
...
@@ -60,6 +63,7 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Transfered " << amount << " from " << #sender << " to " << #recipient); \
}
#define XFER4(chain, sender, recipient, amount) XFER5(chain, sender, recipient, amount, "")
...
...
@@ -75,6 +79,7 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Staked " << amount << " to " << #recipient); \
}
#define STAKE3(chain, account, amount) STAKE4(chain, account, account, amount)
...
...
@@ -86,6 +91,7 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Begin unstake " << amount << " to " << #account); \
}
#define FINISH_UNSTAKE3(chain, account, amount) \
...
...
@@ -96,6 +102,7 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Finish unstake " << amount << " to " << #account); \
}
#define MKPDCR4(chain, owner, key, cfg) \
...
...
@@ -106,6 +113,7 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Create producer " << #owner); \
}
#define MKPDCR3(chain, owner, key) MKPDCR4(chain, owner, key, BlockchainConfiguration{});
#define MKPDCR2(chain, owner) \
...
...
@@ -120,6 +128,7 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Set producer approval from " << #voter << " for " << #producer << " to " << approved); \
}
#define UPPDCR4(chain, owner, key, cfg) \
...
...
@@ -130,5 +139,6 @@
trx.expiration = chain.head_block_time() + 100; \
trx.set_reference_block(chain.head_block_id()); \
chain.push_transaction(trx); \
BOOST_TEST_CHECKPOINT("Update producer " << #owner); \
}
#define UPPDCR3(chain, owner, key) UPPDCR4(chain, owner, key, chain.get_producer(owner).configuration)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录