--- Log opened Tue Jul 29 00:00:55 2025 03:37 < stickies-v> re https://github.com/bitcoin/bitcoin/pull/30595#pullrequestreview-3030139760 - most of my suggestions are only partially incorporated. if helpful to anyone, i'd be happy to fully implement them - didn't do that so far to get conceptual feedback first 05:29 -!- yuvicc [~yuvicc@2409:40e6:12e:2417:614b:a5f2:2960:66ae] has joined #bitcoin-kernel 05:29 -!- yuvicc [~yuvicc@user/yuvicc] has changed host 05:32 < yuvicc> I was playing around with shared_ptr and was thinking if we could use that in c++ wrapper. The ChainMan in c++ wrapper currently uses raw pointer to keep context state alive, I think we can use shared_ptr to make it a bit more safe, not sure whats the trade-offs for that, can anyone have a look!https://github.com/bitcoin/bitcoin/commit/6f3b20c519a5c94e7e9d8d75548e3f74395fe063 05:32 < yuvicc> https://github.com/bitcoin/bitcoin/commit/6f3b20c519a5c94e7e9d8d75548e3f74395fe063 05:34 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Client Quit] 05:34 -!- yuvicc [~yuvicc@2409:40e6:12e:2417:614b:a5f2:2960:66ae] has joined #bitcoin-kernel 05:34 -!- yuvicc [~yuvicc@user/yuvicc] has changed host 05:46 < stickies-v> welcome yuvicc 人 05:47 < stickies-v> would you specifically prefer doing ref counting in the wrapper (vs in the C api), or is that just how you happened to implement it? 05:52 < stickies-v> to give you my view already: i think everyone would benefit from this change, so doing it in the canonical header is my preferred approach. that said, I think the wrapper reflecting that e.g. context has shared ownership might make sense even if we implement internal reference counting 05:53 < stickies-v> i think that's where purpleKarrot's suggested approach differs: by exposing the reference counting in the canonical header, we'd only be using a single reference count 06:20 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Ping timeout: 248 seconds] 06:46 -!- yuvicc [~yuvicc@2409:40e6:12e:2417:614b:a5f2:2960:66ae] has joined #bitcoin-kernel 06:46 -!- yuvicc [~yuvicc@user/yuvicc] has changed host 07:07 < yuvicc> @stickies-v I actually happened to implement it using the already suggested approach by TheCharlatan in the pr. I will dug deep to see if ref counting in the C API is a better approach by using in the language bindings. 07:07 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Quit: yuvicc] 07:11 -!- yuvicc [~yuvicc@user/yuvicc] has joined #bitcoin-kernel 07:37 < stickies-v> I see. curious to hear his thoughts too! 08:32 < TheCharlatan> yuvicc this makes me wish again we'd just be writing everything in rust :P 08:32 < fanquake> 🦀 08:39 < TheCharlatan> The shared context in your patch is a good example for that. You really only want to be borrowing from it, e.g. ensure it remains in scope for the duration of. In much of our codebase we just use references (and pointers for optionals) to express these relationships instead of shared_ptr, e.g. the block manager reference and the mempool pointer in the Chainstate class. 09:06 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Ping timeout: 248 seconds] 10:20 -!- yuvicc [~yuvicc@2409:40e6:12e:2417:614b:a5f2:2960:66ae] has joined #bitcoin-kernel 10:20 -!- yuvicc [~yuvicc@user/yuvicc] has changed host 10:33 < yuvicc> @TheCharlatan Agree, was confused with borrowing and owning. I think we can keep as it is. 10:34 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Quit: yuvicc] 10:45 -!- yuvicc [~yuvicc@2409:40e6:12e:2417:614b:a5f2:2960:66ae] has joined #bitcoin-kernel 10:45 -!- yuvicc [~yuvicc@user/yuvicc] has changed host 10:56 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Ping timeout: 276 seconds] 11:14 -!- yuvicc [~yuvicc@user/yuvicc] has joined #bitcoin-kernel 11:22 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Ping timeout: 272 seconds] 11:36 -!- yuvicc [~yuvicc@2409:40e6:12e:2417:614b:a5f2:2960:66ae] has joined #bitcoin-kernel 11:36 -!- yuvicc [~yuvicc@user/yuvicc] has changed host 11:36 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Client Quit] 14:02 -!- yuvicc [~yuvicc@2409:40e6:12e:2417:614b:a5f2:2960:66ae] has joined #bitcoin-kernel 14:02 -!- yuvicc [~yuvicc@user/yuvicc] has changed host 14:02 -!- yuvicc [~yuvicc@user/yuvicc] has quit [Client Quit] --- Log closed Wed Jul 30 00:00:56 2025