vm: add IterBack to the Stack to iterate bottom-to-top
And use it to build user-facing stack representation because that's the order that C# VM uses.
This commit is contained in:
parent
f3ed91a1f7
commit
05f3329ec0
3 changed files with 43 additions and 5 deletions
|
@ -360,6 +360,17 @@ func (s *Stack) Iter(f func(*Element)) {
|
|||
}
|
||||
}
|
||||
|
||||
// IterBack iterates over all the elements of the stack, starting from the bottom
|
||||
// of the stack.
|
||||
// s.IterBack(func(elem *Element) {
|
||||
// // do something with the element.
|
||||
// })
|
||||
func (s *Stack) IterBack(f func(*Element)) {
|
||||
for e := s.Back(); e != nil; e = e.Prev() {
|
||||
f(e)
|
||||
}
|
||||
}
|
||||
|
||||
// popSigElements pops keys or signatures from the stack as needed for
|
||||
// CHECKMULTISIG.
|
||||
func (s *Stack) popSigElements() ([][]byte, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue