Browse Source

Add timeoffset to getinfo RPC call

Provides a method to get the difference between network adjusted time
and local time from the RPC interface.
0.8
Peter Todd 12 years ago
parent
commit
8686f6467c
  1. 1
      src/rpcwallet.cpp
  2. 7
      src/util.cpp
  3. 1
      src/util.h

1
src/rpcwallet.cpp

@ -75,6 +75,7 @@ Value getinfo(const Array& params, bool fHelp) @@ -75,6 +75,7 @@ Value getinfo(const Array& params, bool fHelp)
obj.push_back(Pair("walletversion", pwalletMain->GetVersion()));
obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance())));
obj.push_back(Pair("blocks", (int)nBestHeight));
obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset()));
obj.push_back(Pair("connections", (int)vNodes.size()));
obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));

7
src/util.cpp

@ -1203,9 +1203,14 @@ void SetMockTime(int64 nMockTimeIn) @@ -1203,9 +1203,14 @@ void SetMockTime(int64 nMockTimeIn)
static int64 nTimeOffset = 0;
int64 GetTimeOffset()
{
return nTimeOffset;
}
int64 GetAdjustedTime()
{
return GetTime() + nTimeOffset;
return GetTime() + GetTimeOffset();
}
void AddTimeData(const CNetAddr& ip, int64 nTime)

1
src/util.h

@ -212,6 +212,7 @@ uint256 GetRandHash(); @@ -212,6 +212,7 @@ uint256 GetRandHash();
int64 GetTime();
void SetMockTime(int64 nMockTimeIn);
int64 GetAdjustedTime();
int64 GetTimeOffset();
std::string FormatFullVersion();
std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments);
void AddTimeData(const CNetAddr& ip, int64 nTime);

Loading…
Cancel
Save