Query the mempool for new pools
Previous mempool filter did not include transactions that use the 'SUMMON' OP_RETURN feature to detect new pools.
This commit is contained in:
parent
96a960a6bd
commit
73e29b1bbe
2 changed files with 15 additions and 5 deletions
|
|
@ -36,7 +36,9 @@ pub fn electrum_get_tip(client: &Client) -> Result<(BlockHeader, u64)> {
|
|||
/// Fetch cauldron mempool transactions
|
||||
pub fn electrum_fetch_mempool(client: &Client) -> Result<HashSet<Txid>> {
|
||||
let filter = json!({
|
||||
"scriptsig": hex::encode(&V2_CONTRACT_TEMPLATE[(V2_CONTRACT_TEMPLATE.len() - 43)..])
|
||||
"scriptsig": hex::encode(&V2_CONTRACT_TEMPLATE[(V2_CONTRACT_TEMPLATE.len() - 43)..]), // cauldron spends
|
||||
"scriptpubkey": hex::encode([0x6a /* op_return */, 0x06 /* push */, b'S', b'U', b'M', b'M', b'O', b'N']), // new pools (potentially)
|
||||
"operation": "union"
|
||||
});
|
||||
|
||||
let response = client.raw_call("mempool.get", [Param::Value(filter)])?;
|
||||
|
|
|
|||
16
src/index.rs
16
src/index.rs
|
|
@ -72,11 +72,20 @@ pub fn update_mempool(db: DBPool, electrum: Arc<Mutex<Client>>) -> Result<()> {
|
|||
.as_secs();
|
||||
|
||||
for tx in txs_to_add {
|
||||
let txid = tx.txid();
|
||||
debug!("mempool add {}", txid.to_hex());
|
||||
db::cauldron::tx::insert_mempool_tx(&db_tx, &txid, current_timestamp)?;
|
||||
let cauldrons: Vec<ParsedContract> = parse_cauldrons_from_tx(&tx);
|
||||
|
||||
if cauldrons.is_empty() {
|
||||
info!("ignoring non-cauldron tx {}", tx.txid());
|
||||
continue;
|
||||
}
|
||||
let txid = tx.txid();
|
||||
db::cauldron::tx::insert_mempool_tx(&db_tx, &txid, current_timestamp)?;
|
||||
info!(
|
||||
"mempool add {} with {} cauldrons",
|
||||
txid.to_hex(),
|
||||
cauldrons.len()
|
||||
);
|
||||
|
||||
insert_utxo_funding(&db_tx, &cauldrons, &txid, false)?;
|
||||
insert_utxo_spending(&db_tx, &cauldrons, &txid, false)?;
|
||||
insert_user_action(&db_tx, &cauldrons, &tx, true)?;
|
||||
|
|
@ -85,7 +94,6 @@ pub fn update_mempool(db: DBPool, electrum: Arc<Mutex<Client>>) -> Result<()> {
|
|||
}
|
||||
|
||||
db::cauldron::pool::update_pool_history(&db_tx, all_cauldrons, None, Some(current_timestamp))?;
|
||||
|
||||
Ok(db_tx.commit()?)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue