示例#1
0
 /**
  * @param OutPointInterface[] $requiredOutpoints
  * @return UtxoInterface[]
  */
 public function fetchView(array $requiredOutpoints)
 {
     try {
         $utxos = [];
         $required = [];
         $cacheHits = [];
         foreach ($requiredOutpoints as $c => $outpoint) {
             $key = $this->outpointSerializer->serialize($outpoint)->getBinary();
             if ($this->set->contains($key)) {
                 list($value, $scriptPubKey) = $this->set->fetch($key);
                 $cacheHits[] = $key;
                 $utxos[] = new Utxo($outpoint, new TransactionOutput($value, new Script(new Buffer($scriptPubKey))));
             } else {
                 $required[] = $outpoint;
             }
         }
         if (empty($required) === false) {
             $utxos = array_merge($utxos, $this->db->fetchUtxoDbList($this->outpointSerializer, $required));
         }
         if ($this->caching) {
             $this->cacheHits = $cacheHits;
         }
         return $utxos;
     } catch (\Exception $e) {
         echo $e->getMessage() . PHP_EOL;
         throw new \RuntimeException('Failed to find UTXOS in set');
     }
 }
示例#2
0
 /**
  * @param OutPointSerializerInterface $outpointSerializer
  * @param array $outpoints
  * @return \BitWasp\Bitcoin\Utxo\Utxo[]
  */
 public function fetchUtxoDbList(OutPointSerializerInterface $outpointSerializer, array $outpoints)
 {
     echo __FUNCTION__ . PHP_EOL;
     return $this->db->fetchUtxoDbList($outpointSerializer, $outpoints);
 }
示例#3
0
 /**
  * @param OutPointInterface[] $required
  * @return UtxoInterface[]
  */
 public function fetchView(array $required)
 {
     return $this->db->fetchUtxoDbList($this->outpointSerializer, $required);
 }