Skip to content

Commit f8869a2

Browse files
committed
Merge pull request bitcoin#330 from btcdrak/68nits
Update BIP68 implementation to match spec
2 parents fe1b3b5 + 0e48a24 commit f8869a2

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

bip-0068.mediawiki

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,21 @@ enum {
6464
/* Setting nSequence to this value for every input in a transaction
6565
* disables nLockTime. */
6666
static const uint32_t SEQUENCE_FINAL = 0xffffffff;
67-
67+
68+
/* Below flags apply in the context of BIP 68*/
6869
/* If this flag set, CTxIn::nSequence is NOT interpreted as a
69-
* relative lock-time. Setting the most significant bit of a
70-
* sequence number disabled relative lock-time. */
70+
* relative lock-time. */
7171
static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG = (1 << 31);
72-
72+
7373
/* If CTxIn::nSequence encodes a relative lock-time and this flag
7474
* is set, the relative lock-time has units of 512 seconds,
7575
* otherwise it specifies blocks with a granularity of 1. */
7676
static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG = (1 << 22);
77-
77+
7878
/* If CTxIn::nSequence encodes a relative lock-time, this mask is
7979
* applied to extract that lock-time from the sequence field. */
8080
static const uint32_t SEQUENCE_LOCKTIME_MASK = 0x0000ffff;
81-
81+
8282
/* In order to use the same number of bits to encode roughly the
8383
* same wall-clock duration, and because blocks are naturally
8484
* limited to occur every 600s on average, the minimum granularity
@@ -87,7 +87,7 @@ static const uint32_t SEQUENCE_LOCKTIME_MASK = 0x0000ffff;
8787
* multiplying by 512 = 2^9, or equivalently shifting up by
8888
* 9 bits. */
8989
static const int SEQUENCE_LOCKTIME_GRANULARITY = 9;
90-
90+
9191
/**
9292
* Calculates the block height and previous block's median time past at
9393
* which the transaction will be considered final in the context of BIP 68.
@@ -174,16 +174,17 @@ bool SequenceLocks(const CTransaction &tx, int flags, std::vector<int>* prevHeig
174174
bool CheckSequenceLocks(const CTransaction &tx, int flags)
175175
{
176176
AssertLockHeld(cs_main);
177+
AssertLockHeld(mempool.cs);
177178

178179
CBlockIndex* tip = chainActive.Tip();
179180
CBlockIndex index;
180181
index.pprev = tip;
181182
// CheckSequenceLocks() uses chainActive.Height()+1 to evaluate
182183
// height based locks because when SequenceLocks() is called within
183-
// CBlock::AcceptBlock(), the height of the block *being*
184-
// evaluated is what is used. Thus if we want to know if a
185-
// transaction can be part of the *next* block, we need to call
186-
// SequenceLocks() with one more than chainActive.Height().
184+
// ConnectBlock(), the height of the block *being*
185+
// evaluated is what is used.
186+
// Thus if we want to know if a transaction can be part of the
187+
// *next* block, we need to use one more than chainActive.Height()
187188
index.nHeight = tip->nHeight + 1;
188189
189190
// pcoinsTip contains the UTXO set for chainActive.Tip()

0 commit comments

Comments
 (0)