Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHAINS-4196 - Fetch upstream 6 24 24 #6

Merged
merged 126 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
e307ad1
blockchain: set the lastflushtime when setting the lastflushhash
kcalvinalvin Jan 3, 2024
a4df044
Fix some typos (#2085)
Thabokani Jan 3, 2024
7fdd92c
docs: fix typo
vuittont60 Jan 9, 2024
048a7ef
database: fix typo
vuittont60 Jan 9, 2024
7df4651
btcutil: fix typo
vuittont60 Jan 9, 2024
6ed54f3
btcec: fix typo
vuittont60 Jan 9, 2024
91cdf0d
Merge pull request #2098 from vuittont60/master
guggero Jan 9, 2024
44abf0a
gitignore: ignore vim files
yyforyongyu Jan 4, 2024
2ad8026
mempool: add new method `checkMempoolAcceptance`
yyforyongyu Nov 3, 2023
ca4261f
btcjson: add `TestMempoolAcceptCmd`
yyforyongyu Nov 3, 2023
889cdb4
multi: add more bitcoind versions to the `BackendVersion`
yyforyongyu Jan 5, 2024
c7e4028
rpcclient: support `testmempoolaccept` for `bitcoind`
yyforyongyu Nov 3, 2023
4842b23
mempool+rpcserver: add interface `TxMempool`
yyforyongyu Nov 29, 2023
6c9f7fe
btcd: add new RPC method `testmempoolaccept`
yyforyongyu Nov 4, 2023
ef54c49
multi: map `btcd` mempool acceptance errors to bitcoind's `testmempoo…
yyforyongyu Dec 5, 2023
c104e72
rpctest: add itest for `testmempoolaccept`
yyforyongyu Nov 29, 2023
8817ebd
integration: print logs to console
yyforyongyu Dec 5, 2023
fbe65bf
gomod: run `go mod tidy` for all modules
yyforyongyu Nov 29, 2023
17fdc52
Merge pull request #2053 from yyforyongyu/testmempoolaccept
Roasbeef Jan 16, 2024
e8a5a55
rpcclient: make sure batch requests are GCed
yyforyongyu Jan 19, 2024
9cda0f7
wire: add `Copy` method to `MsgBlock`
yyforyongyu Jan 21, 2024
c17cf80
netsync: don't update mempool/fee estimator unless we're synced up
kcalvinalvin Jan 22, 2024
62e6af0
Merge pull request #2105 from yyforyongyu/fix-batch-mem-leak
Roasbeef Jan 23, 2024
2a55ff4
refactor: add `make help` command that describes goals
Halimao Jan 22, 2024
8e53942
Merge pull request #2107 from Halimao/refactor/make-help
Roasbeef Jan 24, 2024
13152b3
Merge pull request #2089 from kcalvinalvin/2024-01-03-add-last-flush-…
Roasbeef Jan 24, 2024
c4b1448
feat: Expose newFutureError for developer friendliness
devlzcode Jan 26, 2024
069a0ec
Added 'include_unsafe' option to FundRawTransaction
nikicat Feb 5, 2024
8836219
blockchain: return error in db.View instead of t.Fatal
kcalvinalvin Feb 16, 2024
a0c9e3b
blockchain: add case for pruning stale blocks
kcalvinalvin Feb 16, 2024
5a91ea2
blockchain_test, fullblocktests: add test to check for utxo
kcalvinalvin Feb 21, 2024
d55c55a
Merge pull request #2119 from nikicat/nb/include-unsafe
Roasbeef Feb 22, 2024
5b6d265
Merge pull request #2108 from kcalvinalvin/2024-01-22-dont-update-mem…
Roasbeef Feb 27, 2024
9ea2eea
Merge pull request #2112 from devlzcode/expose-newfutureerror
Roasbeef Feb 27, 2024
3d1150a
blockchain: always relock chainLock for subscription callbacks
kcalvinalvin Feb 27, 2024
dd31767
btcjson: add new command `GetTxSpendingPrevOutCmd`
yyforyongyu Feb 23, 2024
72bbdd5
rpcserver+mempool: implement `gettxspendingprevout` for `btcd`
yyforyongyu Feb 23, 2024
5f71df1
rpcclient: track bitcoind version 24.0.0
yyforyongyu Feb 23, 2024
a033b0d
rpcclient+integration: add new method `GetTxSpendingPrevOut`
yyforyongyu Feb 23, 2024
0d52a89
rpcclient: handle backend versioning in one file
yyforyongyu Feb 23, 2024
9e6070a
rpcclient: start tracking `btcd` version
yyforyongyu Feb 23, 2024
4cf49bd
multi: turn `BackendVersion` into an interface
yyforyongyu Feb 23, 2024
34721f0
rpcclient: replace `ErrBitcoindVersion` with `ErrBackendVersion`
yyforyongyu Feb 27, 2024
0d4ed16
btcd: increase version number to `0.24.1`
yyforyongyu Feb 28, 2024
1a2b599
Merge pull request #2125 from yyforyongyu/add-gettxspendingprevout
Roasbeef Mar 1, 2024
f9da338
addrmgr: fix intermittent addrmanager_internal_test bug
kcalvinalvin Mar 5, 2024
f2caa8f
blockchain: don't rely on BlockHeightByHash for prune height
kcalvinalvin Feb 15, 2024
a254998
blockchain: change reorg utxo cache behavior
kcalvinalvin Feb 20, 2024
78b158d
blockchain: get rid of database as an argument in fetchInputUtxos
kcalvinalvin Mar 5, 2024
99846b0
blockchain: remove unused fetchUtxosMain()
kcalvinalvin Mar 5, 2024
a4f4470
Merge pull request #2131 from kcalvinalvin/2024-03-05-fix-intermitten…
Roasbeef Mar 5, 2024
8d1aa01
blockchain: add another mapslice duplicate entry case
kcalvinalvin Mar 7, 2024
059a668
blockchain: check all the maps first before adding an entry
kcalvinalvin Mar 7, 2024
078815b
blockchain: remove utxoview from the argument in connectBlock
kcalvinalvin Mar 7, 2024
9d2184e
Add check for maximum signature length in ecdsa.ParseDERSignature
SulaimanAminuBarkindo Mar 7, 2024
447c95c
Merge pull request #2122 from kcalvinalvin/2024-02-15-dont-rely-on-he…
Roasbeef Mar 9, 2024
b66f5b8
multi: fix ioutil deprecated function
theedtron Mar 9, 2024
e63bf03
Merge pull request #2123 from kcalvinalvin/2024-02-15-no-utxocache-lo…
Roasbeef Mar 9, 2024
8ed234b
Merge pull request #2134 from kcalvinalvin/2024-03-07-make-duplicate-…
Roasbeef Mar 9, 2024
f0ec9fb
Merge pull request #2128 from kcalvinalvin/2024-02-27-no-panic-for-su…
Roasbeef Mar 9, 2024
aee2705
build: bump version to v0.24.2-beta.rc1
Roasbeef Mar 9, 2024
36683e0
rpcclient: define specific errors for chain backends
yyforyongyu Mar 14, 2024
8abf969
rpcserver: return the plain reject reason from `btcd`
yyforyongyu Mar 14, 2024
2fc99e0
Merge pull request #2138 from yyforyongyu/error-matching
guggero Mar 18, 2024
a90d3d9
Merge pull request #2135 from SulaimanAminuBarkindo/improved-der-sign…
Roasbeef Mar 18, 2024
8b2f43e
Merge pull request #2136 from Roasbeef/btcd-24-0-2-rc1
Roasbeef Mar 18, 2024
2a225e9
wire: add method TxID to MsgTx
ffranr Nov 6, 2023
e39d2eb
Merge pull request #2055 from ffranr/add-msgtx-txid
guggero Mar 25, 2024
75fe7e4
wire: make witnessToHex a TxWitness method called ToHexStrings
ffranr Jun 9, 2023
3cb9f60
fix typos (#2100)
mattn Mar 25, 2024
6ae24a0
mining: remove trailing continue
zhiqiangxu Jan 4, 2024
429d00f
Merge pull request #2091 from zhiqiangxu/rm_trailing_continue
guggero Mar 26, 2024
a03259b
Merge pull request #1991 from ffranr/add-json-support
guggero Mar 26, 2024
bbb6967
btcclient+btcjson: feeRate to BTC/kvB
YusukeShimizu Mar 21, 2024
80b27f5
btcclient+btcjson: add type alias for BTC/kvB
YusukeShimizu Mar 23, 2024
95330bc
chore: fix some comments (#2146)
xiaoxiangxianzi Mar 27, 2024
9851d96
chore: fix typos
xiaoxianBoy Mar 29, 2024
31647e4
btcec: add missing doc comments
ffranr Apr 2, 2024
665eeb5
btcec: add new type `SerializedKey`
ffranr Apr 2, 2024
ae55336
Merge pull request #2142 from YusukeShimizu/feeRate-BTCkvB
Roasbeef Apr 3, 2024
c9c8795
blockchain: add Equals method to blockNode
kcalvinalvin Apr 8, 2024
bc6396d
blockchain: Add IsAncestor method to blockNode
kcalvinalvin Dec 19, 2022
92b24d2
Merge pull request #2150 from xiaoxianBoy/fix-typos
Roasbeef Apr 10, 2024
e4b32e0
Merge pull request #2156 from ffranr/add-pubkey-serialized-type
Roasbeef Apr 10, 2024
5d50f7c
Merge pull request #2153 from kcalvinalvin/2024-04-02-add-is-ancestor
Roasbeef Apr 10, 2024
2f4ff84
fix some typos and make OP_DATA_20 explicit in comment (#2080)
zhiqiangxu Apr 10, 2024
9f93dc1
chore: fix function names in comment (#2163)
goodfirm Apr 10, 2024
64c9011
Update developer_resources.md (#2158)
youngxhui Apr 10, 2024
569155b
doc: fix config documentation for `AgentWhitelist` (#2140)
youngjoon-lee Apr 10, 2024
597b68c
blockchain, workmath: refactor functions to workmath package
kcalvinalvin Apr 2, 2024
337d7f6
fullblocktests, testhelper: refactor out spendableOut
kcalvinalvin Apr 2, 2024
d4644df
fullblocktests, testhelper: move solveBlock to testhelper
kcalvinalvin Apr 2, 2024
62790ac
fullblocktests, testhelper: move opTrueScript and lowFee to testhelper
kcalvinalvin Apr 2, 2024
9093243
fullblocktests, testhelper: move uniqueOpReturnScript to testhelper
kcalvinalvin Apr 2, 2024
59c7d10
fullblocktests, testhelper: move standardCoinbaseScript to testhelper
kcalvinalvin Apr 2, 2024
8ab27b9
fullblocktests, testhelper: move createCoinbaseTx to testhelper
kcalvinalvin Apr 2, 2024
5df1437
fullblocktests, testhelper: move createSpendTx to testhelper
kcalvinalvin Apr 2, 2024
ea39fe0
blockchain: add block generating functions in test code
kcalvinalvin Apr 2, 2024
f93f850
release: add darwin-arm64 to target binaries (#2173)
kcalvinalvin Apr 22, 2024
f1bded4
chaincfg: update dnsseeds (#2174)
kcalvinalvin Apr 23, 2024
126b0ec
chore: fix some typos in comments (#2164)
oftenoccur Apr 26, 2024
6b197d3
chore: fix some function names (#2180)
MarkDaveny Apr 29, 2024
635ae68
blockchain: Add InvalidateBlock() method to BlockChain
kcalvinalvin Apr 2, 2024
689ac6b
blockchain: remove trailing ":" and space on utxocache log
kcalvinalvin May 1, 2024
d65999e
main: add logging if the node is pruned
kcalvinalvin May 1, 2024
2492b01
btcutil/bech32: Added DecodeNoLimitWithVersion
MarcoEzekiel May 9, 2024
04469e6
txscript: make OP_CODESEPARATOR non-standard in non-segwit scripts
ProofOfKeags Apr 10, 2024
da2f3b1
mempool: make txn's below 65 non-witness bytes non-standard
ProofOfKeags Apr 10, 2024
c4ed92f
Merge pull request #2178 from ProofOfKeags/standardness-cleanup
Roasbeef May 21, 2024
b039ee6
Merge pull request #2182 from kcalvinalvin/2024-05-01-fix-logs
Roasbeef May 22, 2024
c467725
Merge pull request #2155 from kcalvinalvin/2024-04-02-invalidate-block
Roasbeef May 22, 2024
d2d286f
Merge pull request #2186 from MarcoEzekiel/DecodeNoLimitVersioned
guggero May 24, 2024
cccaa5f
refactor: specify strconv.ParseFloat bitsize to 64
lilasxie Jun 3, 2024
de41825
Merge pull request #2062 from lilasxie/refactor/parsefloat
guggero Jun 3, 2024
eabc9bf
blockchain: Refactor reorganizeChain to exclude verification
kcalvinalvin Apr 30, 2024
52a8a2a
blockchain: Add ReconsiderBlock to BlockChain
kcalvinalvin Apr 30, 2024
588b2e5
fix: typo (#2184)
yosuzzy Jun 19, 2024
976cbeb
chore: fix some comments (#2191)
VitalikButerinEth Jun 19, 2024
11bd614
Fix struct names (#2169)
coderwander Jun 19, 2024
cd5e5ba
Merge pull request #2196 from Crypt-iQ/2181_eugene
Roasbeef Jun 19, 2024
1cb4d3a
rpcclient, integration: Add invalidateblock and reconsiderblock
kcalvinalvin Jan 9, 2023
0aa80ea
main: Add invalidateblock and reconsiderblock rpc commands
kcalvinalvin Jan 3, 2023
93e7291
Merge pull request #2197 from Crypt-iQ/2183_eugene
Roasbeef Jun 20, 2024
cc4b27c
build: bump version to v0.24.2-beta
Roasbeef Jun 20, 2024
f6db48a
Merge pull request #2201 from Roasbeef/v-0-24-2
guggero Jun 21, 2024
36bc15a
merge master 6-24-24
gitteri Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ btcutil/psbt/coverage.txt

# vim
*.swp
*.swo
/.vim

# Binaries produced by "make build"
/addblock
Expand Down
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ Changes in 0.8.0-beta (Sun May 25 2014)
recent reference client changes
(https://github.com/conformal/btcd/issues/100)
- Raise the maximum signature script size to support standard 15-of-15
multi-signature pay-to-sript-hash transactions with compressed pubkeys
multi-signature pay-to-script-hash transactions with compressed pubkeys
to remain compatible with the reference client
(https://github.com/conformal/btcd/issues/128)
- Reduce max bytes allowed for a standard nulldata transaction to 40 for
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# docker build . -t yourregistry/btcd
#
# You can use the following command to buid an arm64v8 container:
# You can use the following command to build an arm64v8 container:
#
# docker build . -t yourregistry/btcd --build-arg ARCH=arm64v8
#
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ define print
echo $(GREEN)$1$(NC)
endef

#? default: Run `make build`
default: build

#? all: Run `make build` and `make check`
all: build check

# ============
Expand All @@ -55,6 +57,7 @@ $(GOACC_BIN):
@$(call print, "Fetching go-acc")
$(DEPGET) $(GOACC_PKG)@$(GOACC_COMMIT)

#? goimports: Install goimports
goimports:
@$(call print, "Installing goimports.")
$(DEPGET) $(GOIMPORTS_PKG)
Expand All @@ -63,6 +66,7 @@ goimports:
# INSTALLATION
# ============

#? build: Build all binaries, place them in project directory
build:
@$(call print, "Building all binaries")
$(GOBUILD) $(PKG)
Expand All @@ -71,6 +75,7 @@ build:
$(GOBUILD) $(PKG)/cmd/findcheckpoint
$(GOBUILD) $(PKG)/cmd/addblock

#? install: Install all binaries, place them in $GOPATH/bin
install:
@$(call print, "Installing all binaries")
$(GOINSTALL) $(PKG)
Expand All @@ -79,6 +84,7 @@ install:
$(GOINSTALL) $(PKG)/cmd/findcheckpoint
$(GOINSTALL) $(PKG)/cmd/addblock

#? release-install: Install btcd and btcctl release binaries, place them in $GOPATH/bin
release-install:
@$(call print, "Installing btcd and btcctl release binaries")
env CGO_ENABLED=0 $(GOINSTALL) -trimpath -ldflags="-s -w -buildid=" $(PKG)
Expand All @@ -88,15 +94,18 @@ release-install:
# TESTING
# =======

#? check: Run `make unit`
check: unit

#? unit: Run unit tests
unit:
@$(call print, "Running unit tests.")
$(GOTEST_DEV) ./... -test.timeout=20m
cd btcec; $(GOTEST_DEV) ./... -test.timeout=20m
cd btcutil; $(GOTEST_DEV) ./... -test.timeout=20m
cd btcutil/psbt; $(GOTEST_DEV) ./... -test.timeout=20m

#? unit-cover: Run unit coverage tests
unit-cover: $(GOACC_BIN)
@$(call print, "Running unit coverage tests.")
$(GOACC_BIN) ./...
Expand All @@ -109,6 +118,7 @@ unit-cover: $(GOACC_BIN)

cd btcutil/psbt; $(GOACC_BIN) ./...

#? unit-race: Run unit race tests
unit-race:
@$(call print, "Running unit race tests.")
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(GOTEST) -race -test.timeout=20m ./...
Expand All @@ -120,19 +130,27 @@ unit-race:
# UTILITIES
# =========

#? fmt: Fix imports and formatting source
fmt: goimports
@$(call print, "Fixing imports.")
goimports -w $(GOFILES_NOVENDOR)
@$(call print, "Formatting source.")
gofmt -l -w -s $(GOFILES_NOVENDOR)

#? lint: Lint source
lint: $(LINT_BIN)
@$(call print, "Linting source.")
$(LINT)

#? clean: Clean source
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) coverage.txt btcec/coverage.txt btcutil/coverage.txt btcutil/psbt/coverage.txt

#? tidy-module: Run 'go mod tidy' for all modules
tidy-module:
echo "Running 'go mod tidy' for all modules"
scripts/tidy_modules.sh

.PHONY: all \
default \
Expand All @@ -144,3 +162,10 @@ clean:
fmt \
lint \
clean

#? help: Get more info on make commands
help: Makefile
@echo " Choose a command run in btcd:"
@sed -n 's/^#?//p' $< | column -t -s ':' | sort | sed -e 's/^/ /'

.PHONY: help
34 changes: 25 additions & 9 deletions addrmgr/addrmanager_internal_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package addrmgr

import (
"io/ioutil"
"math/rand"
"net"
"os"
Expand All @@ -12,7 +11,7 @@ import (
)

// randAddr generates a *wire.NetAddressV2 backed by a random IPv4/IPv6
// address.
// address. Some of the returned addresses may not be routable.
func randAddr(t *testing.T) *wire.NetAddressV2 {
t.Helper()

Expand Down Expand Up @@ -40,6 +39,23 @@ func randAddr(t *testing.T) *wire.NetAddressV2 {
)
}

// routableRandAddr generates a *wire.NetAddressV2 backed by a random IPv4/IPv6
// address that is always routable.
func routableRandAddr(t *testing.T) *wire.NetAddressV2 {
t.Helper()

var addr *wire.NetAddressV2

// If the address is not routable, try again.
routable := false
for !routable {
addr = randAddr(t)
routable = IsRoutable(addr)
}

return addr
}

// assertAddr ensures that the two addresses match. The timestamp is not
// checked as it does not affect uniquely identifying a specific address.
func assertAddr(t *testing.T, got, expected *wire.NetAddressV2) {
Expand Down Expand Up @@ -91,7 +107,7 @@ func TestAddrManagerSerialization(t *testing.T) {

// We'll start by creating our address manager backed by a temporary
// directory.
tempDir, err := ioutil.TempDir("", "addrmgr")
tempDir, err := os.MkdirTemp("", "addrmgr")
if err != nil {
t.Fatalf("unable to create temp dir: %v", err)
}
Expand All @@ -104,9 +120,9 @@ func TestAddrManagerSerialization(t *testing.T) {

expectedAddrs := make(map[string]*wire.NetAddressV2, numAddrs)
for i := 0; i < numAddrs; i++ {
addr := randAddr(t)
addr := routableRandAddr(t)
expectedAddrs[NetAddressKey(addr)] = addr
addrMgr.AddAddress(addr, randAddr(t))
addrMgr.AddAddress(addr, routableRandAddr(t))
}

// Now that the addresses have been added, we should be able to retrieve
Expand All @@ -131,7 +147,7 @@ func TestAddrManagerV1ToV2(t *testing.T) {

// We'll start by creating our address manager backed by a temporary
// directory.
tempDir, err := ioutil.TempDir("", "addrmgr")
tempDir, err := os.MkdirTemp("", "addrmgr")
if err != nil {
t.Fatalf("unable to create temp dir: %v", err)
}
Expand All @@ -149,9 +165,9 @@ func TestAddrManagerV1ToV2(t *testing.T) {

expectedAddrs := make(map[string]*wire.NetAddressV2, numAddrs)
for i := 0; i < numAddrs; i++ {
addr := randAddr(t)
addr := routableRandAddr(t)
expectedAddrs[NetAddressKey(addr)] = addr
addrMgr.AddAddress(addr, randAddr(t))
addrMgr.AddAddress(addr, routableRandAddr(t))
}

// Then, we'll persist these addresses to disk and restart the address
Expand All @@ -168,7 +184,7 @@ func TestAddrManagerV1ToV2(t *testing.T) {
addrMgr.loadPeers()
addrs := addrMgr.getAddresses()
if len(addrs) != len(expectedAddrs) {
t.Fatalf("expected to find %d adddresses, found %d",
t.Fatalf("expected to find %d addresses, found %d",
len(expectedAddrs), len(addrs))
}
for _, addr := range addrs {
Expand Down
8 changes: 5 additions & 3 deletions blockchain/accept.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ func (b *BlockChain) maybeAcceptBlock(block *btcutil.Block, flags BehaviorFlags)
// Notify the caller that the new block was accepted into the block
// chain. The caller would typically want to react by relaying the
// inventory to other peers.
b.chainLock.Unlock()
b.sendNotification(NTBlockAccepted, block)
b.chainLock.Lock()
func() {
b.chainLock.Unlock()
defer b.chainLock.Lock()
b.sendNotification(NTBlockAccepted, block)
}()

return isMainChain, nil
}
36 changes: 36 additions & 0 deletions blockchain/blockindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ func newBlockNode(blockHeader *wire.BlockHeader, parent *blockNode) *blockNode {
return &node
}

// Equals compares all the fields of the block node except for the parent and
// ancestor and returns true if they're equal.
func (node *blockNode) Equals(other *blockNode) bool {
return node.hash == other.hash &&
node.workSum.Cmp(other.workSum) == 0 &&
node.height == other.height &&
node.version == other.version &&
node.bits == other.bits &&
node.nonce == other.nonce &&
node.timestamp == other.timestamp &&
node.merkleRoot == other.merkleRoot &&
node.status == other.status
}

// Header constructs a block header from the node and returns it.
//
// This function is safe for concurrent access.
Expand Down Expand Up @@ -260,6 +274,28 @@ func (node *blockNode) RelativeAncestorCtx(distance int32) HeaderCtx {
return ancestor
}

// IsAncestor returns if the other node is an ancestor of this block node.
func (node *blockNode) IsAncestor(otherNode *blockNode) bool {
// Return early as false if the otherNode is nil.
if otherNode == nil {
return false
}

ancestor := node.Ancestor(otherNode.height)
if ancestor == nil {
return false
}

// If the otherNode has the same height as me, then the returned
// ancestor will be me. Return false since I'm not an ancestor of me.
if node.height == ancestor.height {
return false
}

// Return true if the fetched ancestor is other node.
return ancestor.Equals(otherNode)
}

// RelativeAncestor returns the ancestor block node a relative 'distance' blocks
// before this node. This is equivalent to calling Ancestor with the node's
// height minus provided distance.
Expand Down
Loading