Add HARDFORK for delete sidechain address
This commit is contained in:
parent
5981d27500
commit
c0203e99e3
3 changed files with 30 additions and 11 deletions
7
libraries/chain/hardfork.d/SIDECHAIN.hf
Normal file
7
libraries/chain/hardfork.d/SIDECHAIN.hf
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef HARDFORK_SIDECHAIN_DELETE_TIME
|
||||||
|
#ifdef BUILD_PEERPLAYS_TESTNET
|
||||||
|
#define HARDFORK_SIDECHAIN_DELETE_TIME (fc::time_point_sec::from_iso_string("2022-11-02T02:00:00"))
|
||||||
|
#else
|
||||||
|
#define HARDFORK_SIDECHAIN_DELETE_TIME (fc::time_point_sec::from_iso_string("2022-11-02T02:00:00"))
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
@ -22,12 +22,14 @@ object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address
|
||||||
const auto &sidechain_addresses_idx = db().get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain_and_expires>();
|
const auto &sidechain_addresses_idx = db().get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain_and_expires>();
|
||||||
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(op.sidechain_address_account, op.sidechain, time_point_sec::maximum()));
|
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(op.sidechain_address_account, op.sidechain, time_point_sec::maximum()));
|
||||||
|
|
||||||
if (addr_itr != sidechain_addresses_idx.end())
|
if (addr_itr != sidechain_addresses_idx.end()) {
|
||||||
{
|
if (db().head_block_time() >= HARDFORK_SIDECHAIN_DELETE_TIME) {
|
||||||
//db().modify(*addr_itr, [&](sidechain_address_object &sao) {
|
db().remove(*addr_itr);
|
||||||
// sao.expires = db().head_block_time();
|
} else {
|
||||||
//});
|
db().modify(*addr_itr, [&](sidechain_address_object &sao) {
|
||||||
db().remove(*addr_itr);
|
sao.expires = db().head_block_time();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& new_sidechain_address_object = db().create<sidechain_address_object>( [&]( sidechain_address_object& obj ){
|
const auto& new_sidechain_address_object = db().create<sidechain_address_object>( [&]( sidechain_address_object& obj ){
|
||||||
|
|
@ -106,11 +108,15 @@ void_result delete_sidechain_address_evaluator::do_apply(const sidechain_address
|
||||||
{ try {
|
{ try {
|
||||||
const auto& idx = db().get_index_type<sidechain_address_index>().indices().get<by_id>();
|
const auto& idx = db().get_index_type<sidechain_address_index>().indices().get<by_id>();
|
||||||
auto sidechain_address = idx.find(op.sidechain_address_id);
|
auto sidechain_address = idx.find(op.sidechain_address_id);
|
||||||
if(sidechain_address != idx.end()) {
|
|
||||||
//db().modify(*sidechain_address, [&](sidechain_address_object &sao) {
|
if (sidechain_address != idx.end()) {
|
||||||
// sao.expires = db().head_block_time();
|
if (db().head_block_time() >= HARDFORK_SIDECHAIN_DELETE_TIME) {
|
||||||
//});
|
db().remove(*sidechain_address);
|
||||||
db().remove(*sidechain_address);
|
} else {
|
||||||
|
db().modify(*sidechain_address, [&](sidechain_address_object &sao) {
|
||||||
|
sao.expires = db().head_block_time();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return void_result();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,9 @@ BOOST_AUTO_TEST_CASE( sidechain_address_delete_test ) {
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("sidechain_address_delete_test");
|
BOOST_TEST_MESSAGE("sidechain_address_delete_test");
|
||||||
|
|
||||||
|
generate_blocks(HARDFORK_SIDECHAIN_DELETE_TIME);
|
||||||
|
generate_block();
|
||||||
|
|
||||||
INVOKE(sidechain_address_add_test);
|
INVOKE(sidechain_address_add_test);
|
||||||
|
|
||||||
GET_ACTOR(alice);
|
GET_ACTOR(alice);
|
||||||
|
|
@ -171,6 +174,9 @@ BOOST_AUTO_TEST_CASE(sidechain_address_delete_create_test) {
|
||||||
|
|
||||||
BOOST_TEST_MESSAGE("sidechain_address_delete_create_test");
|
BOOST_TEST_MESSAGE("sidechain_address_delete_create_test");
|
||||||
|
|
||||||
|
generate_blocks(HARDFORK_SIDECHAIN_DELETE_TIME);
|
||||||
|
generate_block();
|
||||||
|
|
||||||
INVOKE(sidechain_address_add_test);
|
INVOKE(sidechain_address_add_test);
|
||||||
|
|
||||||
GET_ACTOR(alice);
|
GET_ACTOR(alice);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue