/** * @param PartialMerkleTree $tree * @return \BitWasp\Buffertools\Buffer */ public function serialize(PartialMerkleTree $tree) { return $this->getTemplate()->write([$tree->getTxCount(), $tree->getHashes(), $this->bitsToBuffers($tree->getFlagBits())]); }
/** * @param BloomFilter $filter * @return FilteredBlock */ public function filter(BloomFilter $filter) { $vMatch = []; $vHashes = []; foreach ($this->getTransactions() as $tx) { $vMatch[] = $filter->isRelevantAndUpdate($tx); $vHashes[] = $tx->getTxHash(); } return new FilteredBlock($this->getHeader(), PartialMerkleTree::create(count($this->getTransactions()), $vHashes, $vMatch)); }