let mut posn = Vec::with_capacity(channel_txn.len());
for i in 0..channel_txn.len() {
txn.push(&channel_txn[i]);
- posn.push(i as u32 + 1);
+ posn.push(i + 1);
}
$node.block_connected(&header, 1, &txn, &posn);
for i in 2..100 {
hash_map::Entry::Vacant(e) => {
e.insert(self.height);
txn.push(tx);
- txn_idxs.push(idx as u32 + 1);
+ txn_idxs.push(idx + 1);
},
_ => {},
}
fn install_watch_tx(&self, _txid: &Txid, _script_pub_key: &Script) { }
fn install_watch_outpoint(&self, _outpoint: (Txid, u32), _out_script: &Script) { }
fn watch_all_txn(&self) { }
- fn filter_block(&self, _block: &Block) -> Vec<u32> {
+ fn filter_block(&self, _block: &Block) -> Vec<usize> {
Vec::new()
}
fn reentered(&self) -> usize { 0 }
/// Gets the list of transaction indices within a given block that the ChainWatchInterface is
/// watching for.
- fn filter_block(&self, block: &Block) -> Vec<u32>;
+ fn filter_block(&self, block: &Block) -> Vec<usize>;
/// Returns a usize that changes when the ChainWatchInterface's watched data is modified.
/// Users of `filter_block` should pre-save a copy of `reentered`'s return value and use it to
///
/// This also means those counting confirmations using block_connected callbacks should watch
/// for duplicate headers and not count them towards confirmations!
- fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]);
+ fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[usize]);
/// Notifies a listener that a block was disconnected.
/// Unlike block_connected, this *must* never be called twice for the same disconnect event.
/// Height must be the one of the block which was disconnected (not new height of the best chain)
let matched_indexes = self.chain_monitor.filter_block(block);
let mut matched_txn = Vec::new();
for index in matched_indexes.iter() {
- matched_txn.push(&block.txdata[*index as usize]);
+ matched_txn.push(&block.txdata[*index]);
}
reentered = self.block_connected_checked(&block.header, height, matched_txn.as_slice(), matched_indexes.as_slice());
}
/// Returns true if notified listeners registered additional watch data (implying that the
/// block must be re-scanned and this function called again prior to further block_connected
/// calls, see ChainListener::block_connected for more info).
- pub fn block_connected_checked(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]) -> bool {
+ pub fn block_connected_checked(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[usize]) -> bool {
let last_seen = self.chain_monitor.reentered();
let listeners = self.listeners.lock().unwrap();
Err(ChainError::NotSupported)
}
- fn filter_block(&self, block: &Block) -> Vec<u32> {
+ fn filter_block(&self, block: &Block) -> Vec<usize> {
let mut matched_index = Vec::new();
{
let watched = self.watched.lock().unwrap();
for (index, transaction) in block.txdata.iter().enumerate() {
if self.does_match_tx_unguarded(transaction, &watched) {
- matched_index.push(index as u32);
+ matched_index.push(index);
}
}
}
///
/// May return some HTLCs (and their payment_hash) which have timed out and should be failed
/// back.
- pub fn block_connected(&mut self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]) -> Result<(Option<msgs::FundingLocked>, Vec<(HTLCSource, PaymentHash)>), msgs::ErrorMessage> {
+ pub fn block_connected(&mut self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[usize]) -> Result<(Option<msgs::FundingLocked>, Vec<(HTLCSource, PaymentHash)>), msgs::ErrorMessage> {
let mut timed_out_htlcs = Vec::new();
self.holding_cell_htlc_updates.retain(|htlc_update| {
match htlc_update {
}
}
}
+ if height > 0xff_ff_ff || (*index_in_block) > 0xff_ff_ff {
+ panic!("Block was bogus - either height 16 million or had > 16 million transactions");
+ }
+ assert!(txo_idx <= 0xffff); // txo_idx is a (u16 as usize), so this is just listed here for completeness
self.funding_tx_confirmations = 1;
self.short_channel_id = Some(((height as u64) << (5*8)) |
((*index_in_block as u64) << (2*8)) |
F::Target: FeeEstimator,
L::Target: Logger,
{
- fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]) {
+ fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[usize]) {
let header_hash = header.bitcoin_hash();
log_trace!(self.logger, "Block {} at height {} connected with {} txn matched", header_hash, height, txn_matched.len());
let _ = self.total_consistency_lock.read().unwrap();
L::Target: Logger,
C::Target: ChainWatchInterface,
{
- fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], _indexes_of_txn_matched: &[u32]) {
+ fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], _indexes_of_txn_matched: &[usize]) {
let block_hash = header.bitcoin_hash();
{
let mut monitors = self.monitors.lock().unwrap();
pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b, &chaininterface::ChainWatchInterfaceUtil>, chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: u32) {
assert!(chain.does_match_tx(tx));
let mut header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
- notifier.block_connected_checked(&header, 1, &[tx; 1], &[chan_id; 1]);
+ notifier.block_connected_checked(&header, 1, &[tx; 1], &[chan_id as usize; 1]);
for i in 2..CHAN_CONFIRM_DEPTH {
header = BlockHeader { version: 0x20000000, prev_blockhash: header.bitcoin_hash(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
notifier.block_connected_checked(&header, i, &vec![], &[0; 0]);
assert!(nodes[1].chain_monitor.does_match_tx(&tx));
let header = BlockHeader { version: 0x20000000, prev_blockhash: Default::default(), merkle_root: Default::default(), time: 42, bits: 42, nonce: 42 };
- nodes[1].block_notifier.block_connected_checked(&header, 1, &[&tx; 1], &[tx.version; 1]);
+ nodes[1].block_notifier.block_connected_checked(&header, 1, &[&tx; 1], &[tx.version as usize; 1]);
nodes[0].node.handle_funding_locked(&nodes[1].node.get_our_node_id(), &get_event_msg!(nodes[1], MessageSendEvent::SendFundingLocked, nodes[0].node.get_our_node_id()));
- nodes[0].block_notifier.block_connected_checked(&header, 1, &[&tx; 1], &[tx.version; 1]);
+ nodes[0].block_notifier.block_connected_checked(&header, 1, &[&tx; 1], &[tx.version as usize; 1]);
let (funding_locked, _) = create_chan_between_nodes_with_value_confirm_second(&nodes[1], &nodes[0]);
let (announcement, as_update, bs_update) = create_chan_between_nodes_with_value_b(&nodes[0], &nodes[1], &funding_locked);
fn install_watch_tx(&self, _txid: &Txid, _script_pub_key: &Script) { }
fn install_watch_outpoint(&self, _outpoint: (Txid, u32), _out_script: &Script) { }
fn watch_all_txn(&self) { }
- fn filter_block<'a>(&self, _block: &'a Block) -> Vec<u32> {
+ fn filter_block<'a>(&self, _block: &'a Block) -> Vec<usize> {
Vec::new()
}
fn reentered(&self) -> usize { 0 }