コード例 #1
0
ファイル: BloomFilter.php プロジェクト: nmarley/bitcoin-php
 /**
  * @param TransactionInterface $tx
  * @return bool
  */
 public function isRelevantAndUpdate(TransactionInterface $tx)
 {
     $this->updateEmptyFull();
     $found = false;
     if ($this->isFull()) {
         return true;
     }
     if ($this->isEmpty()) {
         return false;
     }
     // Check if the txid hash is in the filter
     $txHash = $tx->getTxId();
     if ($this->containsData($txHash)) {
         $found = true;
     }
     // Check for relevant output scripts. We add the outpoint to the filter if found.
     foreach ($tx->getOutputs() as $vout => $output) {
         $script = $output->getScript();
         $parser = $script->getScriptParser();
         foreach ($parser as $exec) {
             if ($exec->isPush() && $this->containsData($exec->getData())) {
                 $found = true;
                 if ($this->isUpdateAll()) {
                     $this->insertOutPoint($tx->makeOutPoint($vout));
                 } else {
                     if ($this->isUpdatePubKeyOnly()) {
                         $type = ScriptFactory::scriptPubKey()->classify($script);
                         if ($type->isMultisig() || $type->isPayToPublicKey()) {
                             $this->insertOutPoint($tx->makeOutPoint($vout));
                         }
                     }
                 }
             }
         }
     }
     if ($found) {
         return true;
     }
     foreach ($tx->getInputs() as $txIn) {
         if ($this->containsOutPoint($txIn->getOutPoint())) {
             return true;
         }
         $parser = $txIn->getScript()->getScriptParser();
         foreach ($parser as $exec) {
             if ($exec->isPush() > 0 && $this->containsData($exec->getData())) {
                 return true;
             }
         }
     }
     return false;
 }