public function testStaticMethodCodes() { $buffer = Buffer::hex('0001020300010203000102030001020300010203000102030001020300010203'); $block = Inventory::block($buffer); $tx = Inventory::tx($buffer); $filtered = Inventory::filteredBlock($buffer); $this->assertEquals(Inventory::MSG_BLOCK, $block->getType()); $this->assertEquals(Inventory::MSG_TX, $tx->getType()); $this->assertEquals(Inventory::MSG_FILTERED_BLOCK, $filtered->getType()); }
/** * @param Peer $sender * @param TransactionInterface $current */ public function handleTransaction(Peer $sender, TransactionInterface $current) { $hash = $current->getTransactionId(); //echo "TX: $hash\n"; if (!$this->Have($hash)) { $wasMalleated = false; $transaction = $this->fixTransaction($sender, $current, $wasMalleated); $newHash = $transaction->getTransactionId(); if ($wasMalleated) { $this->haveTx[pack("H*", $newHash)] = $transaction; echo "Was malleated: {$hash} - sending to " . (count($this->peers) - 1) . "\n"; foreach ($this->peers as $peer) { if ($sender !== $peer) { $peer->inv([Inventory::tx(Buffer::hex($newHash))]); } } } } else { echo "Already processed? {$hash} \n"; } }