Miners need a way to get new, unmined transactions from other peers. You’ll implement a Pool module that keeps track of transactions (and what UTXOs they spent), similar to Bitcoin’s.
Sending a transaction now just adds it to the pool and broadcasts it to all peers. Mining your own transactions is now not necessary, but, if you do mine, it includes the pooled transactions.
Making a new transaction now ensures that you don’t try to re-use UTXOs that are already in the pool’s list.
See the extensive comments for details about Minicoin’s simplified mempool. Unlike Bitcoin, Minicoin simplified algorithm doesn’t implement spending unconfirmed outputs from pooled transactions.
addTx(tx, UTXOs) validates and adds a transaction to the pool. It checks the inputs against the known-mined UTXOs passed in and the Pool module’s internal list of pool-spent UTXOs. If accepted, the transaction’s spent UTXOs are added to the Pool’s list.
removeBlockTxs(block) takes a newly-mined block and clears out anything it uses from the pool.
onMessage(data) now needs to handle a TRANSACTION message type. You’ll need to add transactions from other peers to the pool.
The LATESTBLOCK and BLOCKCHAIN now clean up the pool when they’re done.
broadcastTx(tx, skippedPeer) sends a transaction to your other peers.
The circle is now complete. Minicoin can have specialized mining nodes and regular user nodes.