def push_bytes(self, value: bytes) -> None: if len(self.values) > 1023: raise FullStack('Stack limit reached') validate_stack_bytes(value) self._append((bytes, value))
def push_int(self, value: int) -> None: if len(self.values) > 1023: raise FullStack('Stack limit reached') validate_stack_int(value) self._append((int, value))
def push_bytes(self, value: bytes) -> None: """ Push a bytes item onto the stack. """ if len(self.values) > 1023: raise FullStack('Stack limit reached') validate_stack_bytes(value) self._append((bytes, value))
def push_int(self, value: int) -> None: """ Push an integer item onto the stack. """ if len(self.values) > 1023: raise FullStack('Stack limit reached') validate_stack_int(value) self._append((int, value))
def push(self, value): """ Push an item onto the stack. """ if len(self.values) > 1023: raise FullStack('Stack limit reached') validate_stack_item(value) self.values.append(value)
def dup(self, position: int) -> None: if len(self.values) > 1023: raise FullStack('Stack limit reached') peek_index = -1 * position try: self._append(self.values[peek_index]) except IndexError: raise InsufficientStack( f"Insufficient stack items for DUP{position}")
def dup(self, position: int) -> None: """ Perform a DUP operation on the stack. """ if len(self.values) > 1023: raise FullStack('Stack limit reached') peek_index = -1 * position try: self._append(self.values[peek_index]) except IndexError: raise InsufficientStack( "Insufficient stack items for DUP{0}".format(position))