diff --git a/blockdag/dag.go b/blockdag/dag.go index 43ba8b5a2..3fe327e47 100644 --- a/blockdag/dag.go +++ b/blockdag/dag.go @@ -1194,7 +1194,19 @@ func (dag *BlockDAG) GetUTXOEntry(outpoint wire.Outpoint) (*UTXOEntry, bool) { // BlockConfirmationsByHash returns the confirmations number for a block with the // given hash. See blockConfirmations for further details. +// +// This function is safe for concurrent access func (dag *BlockDAG) BlockConfirmationsByHash(hash *daghash.Hash) (uint64, error) { + dag.dagLock.RLock() + defer dag.dagLock.RUnlock() + + return dag.BlockConfirmationsByHashNoLock(hash) +} + +// BlockConfirmationsByHashNoLock is lock free version of BlockConfirmationsByHash +// +// This function is unsafe for concurrent access. +func (dag *BlockDAG) BlockConfirmationsByHashNoLock(hash *daghash.Hash) (uint64, error) { if hash.IsEqual(&daghash.ZeroHash) { return 0, nil } @@ -1286,6 +1298,8 @@ func (dag *BlockDAG) oldestChainBlockWithBlueScoreGreaterThan(blueScore uint64) } // IsInSelectedPathChain returns whether or not a block hash is found in the selected path +// +// This method MUST be called with the DAG lock held func (dag *BlockDAG) IsInSelectedPathChain(blockHash *daghash.Hash) bool { return dag.virtual.selectedPathChainSet.containsHash(blockHash) } diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index a4a04a74a..63ce69476 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -12,7 +12,7 @@ services: "--addrindex", # "--generate", "--nodnsseed", - "--miningaddr=dagtest:qrm4zaetvny2yuh4wudf8y43fd20lunkxs8quragg8", + "--miningaddr=dagtest:qrgufg4qzfqacfzrf6xvx46aqedr5nke3qv6a74fex", "--rpcuser=user", "--rpcpass=pass", "--rpclisten=0.0.0.0:18334", @@ -35,7 +35,7 @@ services: "--connect=first", "--rpcuser=user", "--rpcpass=pass", - "--miningaddr=dagtest:qrm4zaetvny2yuh4wudf8y43fd20lunkxs8quragg8", + "--miningaddr=dagtest:qrgufg4qzfqacfzrf6xvx46aqedr5nke3qv6a74fex", "--rpclisten=0.0.0.0:18334", "--rpccert=/go/src/github.com/daglabs/btcd/docker/rpc.cert", "--rpckey=/go/src/github.com/daglabs/btcd/docker/rpc.key" @@ -63,7 +63,7 @@ services: "--connect=first", "--rpcuser=user", "--rpcpass=pass", - "--miningaddr=dagtest:qrm4zaetvny2yuh4wudf8y43fd20lunkxs8quragg8", + "--miningaddr=dagtest:qrgufg4qzfqacfzrf6xvx46aqedr5nke3qv6a74fex", "--rpclisten=0.0.0.0:18334", "--rpccert=/go/src/github.com/daglabs/btcd/docker/rpc.cert", "--rpckey=/go/src/github.com/daglabs/btcd/docker/rpc.key"