Blockchain-enabled peer-to-peer energy trading provides a method for neighbours and communities to trade energy generated from local and distributed renewable energy sources. Effective matching can facilitate greater energy efficiency during transmission, increases user welfare through preference and improves power quality. The proposed algorithm builds upon work to develop a system of scoring an energy transaction. It uses a McAfee-priced double auction, and scores based upon preference of price, locality, and energy generation type, alongside the quantity of energy being traded. The algorithm pre-evaluates transactions to determine the optimal transactional pathway. The transaction carried out is that leading to the greatest cumulative score. Simulated over a range of scenarios, the proposed algorithm provides an average increase in user welfare of 75%. Commercially, the algorithm may be deployed in small to large settlements whilst remaining stable. By reducing power loss, the algorithm allows consumers to save 25% on their cost of energy, whilst providing a 50% increase in the revenue earned by prosumers.