Skip to content

Commit

Permalink
Fixed bug in nTargetTimespan value being too small
Browse files Browse the repository at this point in the history
  • Loading branch information
John Smith committed Jun 2, 2014
1 parent 7c10bf4 commit b2e2b99
Show file tree
Hide file tree
Showing 4 changed files with 360 additions and 344 deletions.
8 changes: 6 additions & 2 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,10 @@ Value getblocktemplate(const Array& params, bool fHelp)

if(modeval.type() == str_type)
strMode = modeval.get_str();
else if(modeval.type() == null_type)
{
//do nothing
}
else
throw JSONRPCError(-8, "Invalid mode");
}
Expand Down Expand Up @@ -2308,14 +2312,14 @@ Value getblocktemplate(const Array& params, bool fHelp)
result.push_back(Pair("coinbaseaux", aux));
result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue));
result.push_back(Pair("target", hashTarget.GetHex()));
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast() + 1));
result.push_back(Pair("mutable", aMutable));
result.push_back(Pair("noncerange", "00000000ffffffff"));
result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS));
result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE));
result.push_back(Pair("curtime", (int64_t)pblock->nTime));
result.push_back(Pair("bits", HexBits(pblock->nBits)));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1)));
result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight + 1)));

return result;
}
Expand Down
52 changes: 26 additions & 26 deletions src/json/json_spirit_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,47 @@

namespace json_spirit
{
template< class Obj_t, class Map_t >
template< class Obj_t, class Map_t >
void obj_to_map( const Obj_t& obj, Map_t& mp_obj )
{
mp_obj.clear();
{
mp_obj.clear();

for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
{
mp_obj[ i->name_ ] = i->value_;
}
for( typename Obj_t::const_iterator i = obj.begin(); i != obj.end(); ++i )
{
mp_obj[ i->name_ ] = i->value_;
}
}

template< class Obj_t, class Map_t >
template< class Obj_t, class Map_t >
void map_to_obj( const Map_t& mp_obj, Obj_t& obj )
{
obj.clear();
{
obj.clear();

for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
{
obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
}
for( typename Map_t::const_iterator i = mp_obj.begin(); i != mp_obj.end(); ++i )
{
obj.push_back( typename Obj_t::value_type( i->first, i->second ) );
}
}

typedef std::map< std::string, Value > Mapped_obj;
typedef std::map< std::string, Value > Mapped_obj;

#ifndef BOOST_NO_STD_WSTRING
typedef std::map< std::wstring, wValue > wMapped_obj;
typedef std::map< std::wstring, wValue > wMapped_obj;
#endif

template< class Object_type, class String_type >
template< class Object_type, class String_type >
const typename Object_type::value_type::Value_type& find_value( const Object_type& obj, const String_type& name )
{
for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
{
for( typename Object_type::const_iterator i = obj.begin(); i != obj.end(); ++i )
{
if( i->name_ == name )
{
return i->value_;
}
}

return Object_type::value_type::Value_type::null;
if( i->name_ == name )
{
return i->value_;
}
}

return Object_type::value_type::Value_type::null;
}
}

#endif
Loading

0 comments on commit b2e2b99

Please sign in to comment.