Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
2001Assume(prev_group != SENTINEL);2002if (entries[cur_group].deps.Overlaps(entries[prev_group].group)) {2003// There is a dependency between cur_group and prev_group; merge prev_group2004// into cur_group. The group/deps/feerate fields of prev_group remain unchanged2005// but become unused.2006entries[cur_group].group |= entries[prev_group].group;2007entries[cur_group].deps |= entries[prev_group].deps;2008entries[cur_group].feerate += entries[prev_group].feerate;2009// Make the first of the current group point to the tail of the previous group.2010entries[entries[cur_group].first_tx].prev_tx = prev_group;2011// The first of the previous group becomes the first of the newly-merged group.2012entries[cur_group].first_tx = entries[prev_group].first_tx;2013// The previous group becomes whatever group was before the former one.2014prev_group = entries[prev_group].prev_group;2015entries[cur_group].prev_group = prev_group;2016} else {2017// There is no dependency between cur_group and prev_group; swap them.2018DepGraphIndex preprev_group = entries[prev_group].prev_group;2019// If PP, P, C, N were the old preprev, prev, cur, next groups, then the new2020// layout becomes [PP, C, P, N]. Update prev_groups to reflect that order.2021entries[next_group].prev_group = prev_group;2022entries[prev_group].prev_group = cur_group;2023entries[cur_group].prev_group = preprev_group;2024// The current group remains the same, but the groups before/after it have2025// changed.2026next_group = prev_group;2027prev_group = preprev_group;2028}2029}2030}2032// Convert the entries back to linearization (overwriting the existing one).2033DepGraphIndex cur_group = entries[0].prev_group;2034DepGraphIndex done = 0;2035while (cur_group != SENTINEL) {2036DepGraphIndex cur_tx = cur_group;2037// Traverse the transactions of cur_group (from back to front), and write them in the2038// same order during odd passes, and reversed (front to back) in even passes.2039if (rev) {2040do {2041*(linearization.begin() + (done++)) = cur_tx - 1;2042cur_tx = entries[cur_tx].prev_tx;2043} while (cur_tx != NO_PREV_TX);2044} else {2045do {2046*(linearization.end() - (++done)) = cur_tx - 1;2047cur_tx = entries[cur_tx].prev_tx;2048} while (cur_tx != NO_PREV_TX);2049}2050cur_group = entries[cur_group].prev_group;2051}2052Assume(done == linearization.size());2053}2054}2056} // namespace cluster_linearize2058#endif // BITCOIN_CLUSTER_LINEARIZE_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.