| The essence of blockchain technology is a decentralized distributed ledger.The transaction is generated by the transaction payer,propagated to other nodes through the P2P network,and finally stored on the block by the mining node.This thesis describes the process of generating transactions by the payer and the process of selecting transactions by mining nodes based on UTXO(Unspent Transaction Output)models.On the basis of not changing the transaction structure,this thesis proposes an innovative transaction-level block expansion method:reduce the size of the transaction and store more transactions on the block,that is to achieve block expansion from the perspective of generating transaction and generating block respectively,where,the size of a transaction refers to the number of bytes occupied by the transaction data.Transaction generating is the process of constructing transaction inputs according to the required payment amount and constructing transaction outputs according to the transaction receiver.This thesis improves the mathematical model of transaction generating and reduces transaction size by reducing the number of transaction inputs and the number of transaction outputs.Creating a transaction output for a transaction receiver can achieve the least amount of transaction output.For the transaction inputs,this thesis uses the greedy algorithm and genetic algorithm to search for the transaction inputs with the smallest number but the sum of the amount is closest to the required payment amount.There is an upper limit on the number of bytes used to store transactions in a block,thus,reduce the size of a transaction can allow a block to accommodate more transactions.In addition,because the calculation of transaction fees is related to the size of the transaction,reducing the size of transaction can reduce transaction fees.The mining nodes choose transactions to be packaged into blocks from the transaction pool for the purpose of obtaining high transaction fees.Only legal blocks will be consented by other nodes,so mining nodes need to ensure that the selected transactions are legal.This thesis will detail the legality verification rules for transactions and the legality verification rules for blocks.The selection of transactions by mining nodes is a completely autonomous process.Selecting as many transactions as possible to the block can achieve block expansion,but it needs to take the transaction fee reward into account.When the block can fully accommodate the transactions in the transaction pool,all transactions in the transaction pool are packaged into the block,which realizes the block expansion and meets the needs of mining nodes.When the block cannot fully accommodate the transactions in the transaction pool,the mining node should select transactions to make the block full to achieve block expansion,and the mining node will preferentially select those transaction combinations with high transaction fees.Usually,the priority is set for the transaction according to the transaction fee,and then the transaction is selected according to the priority.This thesis also gives another solution which takes the process of selecting transactions as a 0-1 knapsack problem,and then uses dynamic programming to select transactions to ensure that mining nodes get higher transaction fees. |