The Social Internet of Things (Social IoT) introduces a fresh approach to promote the usability of IoT networks and enhance service discovery by incorporating social contexts. However, this approach encounters various challenges that impact its performance and reliability. One of the most prominent challenges is trust, specifically trust-related attacks, where certain users engage in malicious behaviors and launch attacks to spread harmful services. To ensure a trustworthy experience for end-users and prevent such attacks in real-time, it is highly significant to incorporate a trust management mechanism within the Social IoT network. To address this challenge, we propose a novel trust management mechanism that leverages blockchain technology. By integrating this technology, we aim to prevent trust-related attacks and create a secure environment. Additionally, we introduce a new consensus protocol for the blockchain called Spark-based Proof of Trust-related Attacks (SPoTA). This protocol is designed to process stream transactions in real-time using Apache Spark, a distributed stream processing engine. To implement SPoTA, we have developed a new classifier utilizing Spark Libraries. This classifier is capable of accurately categorizing transactions as either malicious or secure. As new transaction streams are read, the classifier is employed to classify and assign a label to each stream. This label assists the SPoTA protocol in making informed decisions regarding the validation or rejection of transactions. Our research findings demonstrate the effectiveness of our classifier in predicting malicious transactions, outstripping our previous works and other approaches reported in the literature. Additionally, our new protocol exhibits improved transaction processing times.