Blockchain as a technological foundation for achieving secure data transmission between peers is a very promising platform in various fields. PoW is a widely used consensus algorithm in blockchain systems, but it still faces issues such as low throughput and resource waste. In order to address these issues, we have proposed a new consensus protocol called DMKT, which aims to improve the system's throughput and reduce resource waste. The DMKT model dynamically adjusts the mining difficulty of nodes based on their trust values. In this paper, we use machine learning to classify transactions generated by nodes and calculate the classification results, which are used as parameters to calculate node trust values. We also incorporate the inherent properties of nodes in the blockchain system and the evaluation attributes of neighbors into the system calculation of trust values. Additionally, in this model, the trust values of the nodes are recalculated after each cycle, thus avoiding the problem of power concentration caused by always selecting a single node to maintain the accounting.Through this dynamic adjustment of node mining difficulty, the trust value increases, the mining difficulty decreases, and the trust value decreases, the mining difficulty increases, thus improving system performance.