Commit Graph

7 Commits

Author SHA1 Message Date
yyforyongyu
4ee862e3be
blockcache: fix heap escape in GetBlock
This commit fixes a heap escape found in `GetBlock`. This happens
because the `msgBlock` is a pointer returned from `getBlockImpl`, and
the whole `getBlockImpl` escapes to the heap because it's referenced in
two places,
- in the `Cache`, it's used as a reference type to create the new block.
- this pointer is also returned and now needs to stay on the heap.

The fix is simple, we now make a copy of the block and use the copy
instead, freeing `getBlockImpl` from the heap.
2024-01-23 17:08:57 +08:00
Olaoluwa Osuntokun
a7d6826f60
multimutex: remove HashMutex, make Mutex type a type param
In this commit, we eliminate some code duplication by removing the old
`HashMutex` struct as it just duplicates all the code with a different
type (uint64 and hash). We then make the main Mutex struct take a type
param, so the key can be parametrized when the struct is instantiated.
2023-06-01 17:39:49 -07:00
Olaoluwa Osuntokun
a15c45231e
multi: bump neutrino+btcwallet versions, use new generic lru cache 2023-02-21 17:28:48 -08:00
Michael Street
46444d9154
blockcache: fix datarace in blockcache_test
mockChainBackend simulates a chain backend and
tracks the number of calls via a private property
called chainCallCount.  This commit uses a write
mutex instead of read mutex in the call to GetBlock,
adds a getter method to access chainCallCount
with a read mutex and uses a write mutex in
resetChainCallCount.
2022-10-13 10:32:27 -04:00
Tommy Volk
834756c53c multi: migrate assert.NoError to require.NoError 2022-07-05 16:41:08 +00:00
Oliver Gugger
7dfe4018ce
multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Elle Mouton
275d55c9e6 blockcache: add blockcache package
This commit adds a new blockcache package along with the GetBlock method
to be used along with the blockcache.
2021-04-28 09:46:11 +02:00