Track dropped txs in multi-address subscription
This commit is contained in:
		
							parent
							
								
									77a526b91c
								
							
						
					
					
						commit
						8f7895cb2e
					
				@ -27,7 +27,7 @@ import mempool from './mempool';
 | 
				
			|||||||
interface AddressTransactions {
 | 
					interface AddressTransactions {
 | 
				
			||||||
  mempool: MempoolTransactionExtended[],
 | 
					  mempool: MempoolTransactionExtended[],
 | 
				
			||||||
  confirmed: MempoolTransactionExtended[],
 | 
					  confirmed: MempoolTransactionExtended[],
 | 
				
			||||||
  removed: string[],
 | 
					  removed: MempoolTransactionExtended[],
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// valid 'want' subscriptions
 | 
					// valid 'want' subscriptions
 | 
				
			||||||
@ -572,15 +572,16 @@ class WebsocketHandler {
 | 
				
			|||||||
      if (client['track-addresses']) {
 | 
					      if (client['track-addresses']) {
 | 
				
			||||||
        const addressMap: { [address: string]: AddressTransactions } = {};
 | 
					        const addressMap: { [address: string]: AddressTransactions } = {};
 | 
				
			||||||
        for (const [address, key] of Object.entries(client['track-addresses'] || {})) {
 | 
					        for (const [address, key] of Object.entries(client['track-addresses'] || {})) {
 | 
				
			||||||
          const foundTransactions = Array.from(addressCache[key as string]?.values() || []);
 | 
					          const newTransactions = Array.from(addressCache[key as string]?.values() || []);
 | 
				
			||||||
 | 
					          const removedTransactions = Array.from(removedAddressCache[key as string]?.values() || []);
 | 
				
			||||||
          // txs may be missing prevouts in non-esplora backends
 | 
					          // txs may be missing prevouts in non-esplora backends
 | 
				
			||||||
          // so fetch the full transactions now
 | 
					          // so fetch the full transactions now
 | 
				
			||||||
          const fullTransactions = (config.MEMPOOL.BACKEND !== 'esplora') ? await this.getFullTransactions(foundTransactions) : foundTransactions;
 | 
					          const fullTransactions = (config.MEMPOOL.BACKEND !== 'esplora') ? await this.getFullTransactions(newTransactions) : newTransactions;
 | 
				
			||||||
          if (fullTransactions?.length) {
 | 
					          if (fullTransactions?.length) {
 | 
				
			||||||
            addressMap[address] = {
 | 
					            addressMap[address] = {
 | 
				
			||||||
              mempool: fullTransactions,
 | 
					              mempool: fullTransactions,
 | 
				
			||||||
              confirmed: [],
 | 
					              confirmed: [],
 | 
				
			||||||
              removed: [],
 | 
					              removed: removedTransactions,
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -593,15 +594,16 @@ class WebsocketHandler {
 | 
				
			|||||||
      if (client['track-scriptpubkeys']) {
 | 
					      if (client['track-scriptpubkeys']) {
 | 
				
			||||||
        const spkMap: { [spk: string]: AddressTransactions } = {};
 | 
					        const spkMap: { [spk: string]: AddressTransactions } = {};
 | 
				
			||||||
        for (const spk of client['track-scriptpubkeys'] || []) {
 | 
					        for (const spk of client['track-scriptpubkeys'] || []) {
 | 
				
			||||||
          const foundTransactions = Array.from(addressCache[spk as string]?.values() || []);
 | 
					          const newTransactions = Array.from(addressCache[spk as string]?.values() || []);
 | 
				
			||||||
 | 
					          const removedTransactions = Array.from(removedAddressCache[spk as string]?.values() || []);
 | 
				
			||||||
          // txs may be missing prevouts in non-esplora backends
 | 
					          // txs may be missing prevouts in non-esplora backends
 | 
				
			||||||
          // so fetch the full transactions now
 | 
					          // so fetch the full transactions now
 | 
				
			||||||
          const fullTransactions = (config.MEMPOOL.BACKEND !== 'esplora') ? await this.getFullTransactions(foundTransactions) : foundTransactions;
 | 
					          const fullTransactions = (config.MEMPOOL.BACKEND !== 'esplora') ? await this.getFullTransactions(newTransactions) : newTransactions;
 | 
				
			||||||
          if (fullTransactions?.length) {
 | 
					          if (fullTransactions?.length) {
 | 
				
			||||||
            spkMap[spk] = {
 | 
					            spkMap[spk] = {
 | 
				
			||||||
              mempool: fullTransactions,
 | 
					              mempool: fullTransactions,
 | 
				
			||||||
              confirmed: [],
 | 
					              confirmed: [],
 | 
				
			||||||
              removed: [],
 | 
					              removed: removedTransactions,
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user