Skip to content

Commit 6726694

Browse files
shaavanhebasto
authored andcommitted
Add getBlockTime interface method in src/interfaces/chain.h
- This method would allow to get the blocktime value of the block at the given height. Github-Pull: #220 Rebased-From: 1fce853
1 parent e103a00 commit 6726694

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/interfaces/chain.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ class Chain
139139
//! Get block hash. Height must be valid or this function will abort.
140140
virtual uint256 getBlockHash(int height) = 0;
141141

142+
//! Get block time, Height must be valid or this function will abort.
143+
virtual int64_t getBlockTime(int height) = 0;
144+
142145
//! Check that the block is available on disk (i.e. has not been
143146
//! pruned), and contains transactions.
144147
virtual bool haveBlockOnDisk(int height) = 0;

src/node/interfaces.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,11 @@ class ChainImpl : public Chain
555555
LOCK(::cs_main);
556556
return Assert(chainman().ActiveChain()[height])->GetBlockHash();
557557
}
558+
int64_t getBlockTime(int height) override
559+
{
560+
LOCK(::cs_main);
561+
return Assert(chainman().ActiveChain()[height])->GetBlockTime();
562+
}
558563
bool haveBlockOnDisk(int height) override
559564
{
560565
LOCK(::cs_main);

0 commit comments

Comments
 (0)