hoped for thy salvation
In our day the word hope has been weakened to mean a desire that may or may not come, but this word hope has a stronger connotation. Our hope in Christ is both steadfast and sure (Heb. 6:19). It is not something that we wish to have if everything works out all right.
The psalmist hoped for God's salvation. Anyone who hopes for salvation receives it, Titus 1:2 In hope of eternal life, which God, that cannot lie, promised before the world began; Salvation is eternal life, and it comes with a certainty that is included in the meaning of this word hope.
and done thy commandments
Notice that salvation is God's salvation, not David's. Also, the commandments are God's, not ours. We have had enough of the traditions of men (Gal. 1:14), and the tradition of the elders (Matt. 15:2); now we must turn our attention to the commandments of God. It is His word and His work that account to something, not our own feeble efforts.
If we, then, have His salvation, it is imperative that we do His commandments. This is not a choice but a commandment. Jesus said in John 14:15 If ye love me, keep my commandments. This is a sobering thought and should shake us to the core and cause us to, first, hope in God's salvation and, second, to be determined to keep God's commandments.
Eccles. 12:13 Let us hear the conclusion of the whole matter: Fear God, and keep his commandments: for this is the whole duty of man.