Generate hardfork.hpp from hardfork.d directory #511

This commit is contained in:
theoreticalbts 2016-01-08 15:42:08 -05:00
parent b5480db341
commit 3edaf15652
19 changed files with 153 additions and 44 deletions

1
.gitignore vendored
View file

@ -8,6 +8,7 @@ Makefile
compile_commands.json
moc_*
*.moc
hardfork.hpp
libraries/utilities/git_revision.cpp

View file

@ -1,3 +1,9 @@
add_custom_target( build_hardfork_hpp
COMMAND cat-parts hardfork.d include/graphene/chain/hardfork.hpp )
add_dependencies( build_hardfork_hpp cat-parts )
file(GLOB HEADERS "include/graphene/chain/*.hpp")
if( GRAPHENE_DISABLE_UNITY_BUILD )
@ -78,8 +84,10 @@ add_library( graphene_chain
block_database.cpp
${HEADERS}
include/graphene/chain/hardfork.hpp
)
add_dependencies( graphene_chain build_hardfork_hpp )
target_link_libraries( graphene_chain fc graphene_db )
target_include_directories( graphene_chain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )

View file

@ -0,0 +1,10 @@
/*****************************************
* *
* This file is automatically generated. *
* To create new hardfork, please modify *
* the .hf files in hardfork.d instead *
* of modifying this file. *
* *
*****************************************/
#pragma once

View file

@ -0,0 +1,4 @@
// #357 Disallow publishing certain malformed price feeds
#ifndef HARDFORK_357_TIME
#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 ))
#endif

View file

@ -0,0 +1,4 @@
// #359 Allow digits in asset name
#ifndef HARDFORK_359_TIME
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 ))
#endif

View file

@ -0,0 +1,4 @@
// #409 Allow creation of sub-assets
#ifndef HARDFORK_409_TIME
#define HARDFORK_409_TIME (fc::time_point_sec( 1446652800 ))
#endif

View file

@ -0,0 +1,4 @@
// #413 Add operation to claim asset fees
#ifndef HARDFORK_413_TIME
#define HARDFORK_413_TIME (fc::time_point_sec( 1446652800 ))
#endif

View file

@ -0,0 +1,4 @@
// #415 Default accept policy for asset with no whitelist authorities
#ifndef HARDFORK_415_TIME
#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 ))
#endif

View file

@ -0,0 +1,4 @@
// #416 enforce_white_list is inconsistently applied
#ifndef HARDFORK_416_TIME
#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 ))
#endif

View file

@ -0,0 +1,4 @@
// #419 Account can pay fees in blacklisted asset
#ifndef HARDFORK_419_TIME
#define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 ))
#endif

View file

@ -0,0 +1,4 @@
// #436 Prevent margin call from being triggered unless feed < call price
#ifndef HARDFORK_436_TIME
#define HARDFORK_436_TIME (fc::time_point_sec( 1450288800 ))
#endif

View file

@ -0,0 +1,4 @@
// #445 Refund create order fees on cancel
#ifndef HARDFORK_445_TIME
#define HARDFORK_445_TIME (fc::time_point_sec( 1450288800 ))
#endif

View file

@ -0,0 +1,4 @@
// #453 Hardfork to retroactively correct referral percentages
#ifndef HARDFORK_453_TIME
#define HARDFORK_453_TIME (fc::time_point_sec( 1450288800 ))
#endif

View file

@ -0,0 +1,4 @@
// #480 Fix non-BTS MIA core_exchange_rate check
#ifndef HARDFORK_480_TIME
#define HARDFORK_480_TIME (fc::time_point_sec( 1450378800 ))
#endif

View file

@ -0,0 +1,4 @@
// #483 Operation history numbering change
#ifndef HARDFORK_483_TIME
#define HARDFORK_483_TIME (fc::time_point_sec( 1450378800 ))
#endif

View file

@ -1,44 +0,0 @@
/*
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
*
* The MIT License
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#pragma once
#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 ))
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 ))
#define HARDFORK_409_TIME (fc::time_point_sec( 1446652800 ))
#define HARDFORK_413_TIME (fc::time_point_sec( 1446652800 ))
#define HARDFORK_415_TIME (fc::time_point_sec( 1446652800 ))
#define HARDFORK_416_TIME (fc::time_point_sec( 1446652800 ))
#define HARDFORK_419_TIME (fc::time_point_sec( 1446652800 ))
// #436 Prevent margin call from being triggered unless feed < call price
#define HARDFORK_436_TIME (fc::time_point_sec( 1450288800 ))
// #445 Refund create order fees on cancel
#define HARDFORK_445_TIME (fc::time_point_sec( 1450288800 ))
// #453 Hardfork to retroactively correct referral percentages
#define HARDFORK_453_TIME (fc::time_point_sec( 1450288800 ))
#define HARDFORK_480_TIME (fc::time_point_sec( 1450378800 ))
// #483 Operation history numbering change
#define HARDFORK_483_TIME (fc::time_point_sec( 1450378800 ))

View file

@ -1,3 +1,4 @@
add_subdirectory( build_helpers )
add_subdirectory( cli_wallet )
add_subdirectory( genesis_util )
add_subdirectory( witness_node )

View file

@ -0,0 +1,8 @@
add_executable( cat-parts cat-parts.cpp )
if( UNIX AND NOT APPLE )
set(rt_library rt )
endif()
# we only actually need Boost, but link against FC for now so we don't duplicate it.
target_link_libraries( cat-parts PRIVATE fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )

View file

@ -0,0 +1,77 @@
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
int main( int argc, char** argv, char** envp )
{
if( argc != 3 )
{
std::cerr << "syntax: cat-parts DIR OUTFILE" << std::endl;
return 1;
}
boost::filesystem::path p(argv[1]);
try
{
std::vector< boost::filesystem::path > v;
for( boost::filesystem::directory_iterator it(p);
it != boost::filesystem::directory_iterator();
++it )
{
boost::filesystem::path pit = it->path();
std::string spit = pit.generic_string();
size_t n = spit.length();
if( n <= 3 )
continue;
if( spit.substr(n-3, 3) != ".hf" )
continue;
v.push_back( pit );
}
std::sort( v.begin(), v.end() );
// open each file and grab its contents, concatenating into single stringstream
std::stringstream ss_data;
for( const boost::filesystem::path& p : v )
{
boost::filesystem::ifstream ifs(p);
ss_data << ifs.rdbuf();
}
std::string new_data = ss_data.str();
boost::filesystem::path opath(argv[2]);
if( boost::filesystem::exists( opath ) )
{
boost::filesystem::ifstream ifs(opath);
std::stringstream ss_old_data;
ss_old_data << ifs.rdbuf();
std::string old_data = ss_old_data.str();
if( old_data == new_data )
{
std::cerr << "File " << opath << " up-to-date with .d directory" << std::endl;
return 0;
}
}
{
boost::filesystem::ofstream ofs(opath);
ofs.write( new_data.c_str(), new_data.length() );
}
std::cerr << "Built " << opath << " from .d directory" << std::endl;
}
catch( const boost::filesystem::filesystem_error& e )
{
std::cout << e.what() << std::endl;
return 1;
}
return 0;
}