2023 Jan 16
Interesting, to get a
Channel
fromChannelManager
(with somehtlc: ClaimableHTLC
), you have to do something like this:let short_channel_id = htlc.prev_hop.short_channel_id; let (counterparty_node_id, chan_id) = self.short_to_chan_info.read().unwrap().get(&short_channel_id).cloned().unwrap(); let per_peer_state = self.per_peer_state.read().unwrap(); let peer_state = per_peer_state.get(counterparty_node_id).unwrap().lock().unwrap(); let chan = peer_state.channel_by_id.get(chan_id).unwrap();
- There might be a better way I just don’t know, but that’s how it seems to be done. I would’ve thought there might just be some hashmap of channel ids to channels as a field of
ChannelManager
, but it’s interesting it’s kept inpeer_state
.
- There might be a better way I just don’t know, but that’s how it seems to be done. I would’ve thought there might just be some hashmap of channel ids to channels as a field of
Getting a lot better at Helix. Some nifty shortcuts:
]g
to go to next change,space f
for file picker,m i <char>
to do vim’sv i <char>
i.e. matching inside,space k
to pull up documentation on a variable/type/etc.,g d
to go to definition,g r
to go to references. Still having trouble navigating the jumplist, and going back to previous places/managing different places at one time.Learned about the
ChannelManager
lock order. I ran into some trouble where I was violating the lock order, and my solution was to just cloneshort_to_chan_info
to release the lock so I could then grab the lock forper_peer_state
. It seemed there was no other way to find a channel from a short channel id, but it felt like cheating, although I saw it done somewhere else. I’ll hopefully come to understand more about why the lock order is the way it is as I work with the code base more.Also noticing there are several different structs and enums defined relating to failure codes/messages that could maybe be standardized in the future.
Did a lot today. Finally feeling a little more familiar with at least the area of the repo I’ve been working with.