Reputation-Based trust mechanism can efficiently solve the problems of virus flooding and malicious behaviors in P2P network. Most of the existing trust mechanisms use a single reputation value to depict the node's reliability, which cannot prevent malicious nodes from concealing dishonest selling behaviors with honest buying behaviors, and cannot separate the new node from the malicious one. This paper provides a new distributed trust mechanism, which iteratively calculates for each node a global seller reputation value and a global buyer reputation value based on transaction history, and whether a node is trustable or not can be identified from them. Comparison experiments and performance analysis between the mechanism and EigenTrust show that the mechanism can reduce the global reputation value of malicious node rapidly, restrain collusion attack, and decrease probability malicious transactions.