Packages

case class ConditionalCounter(trueCount: Int, falseAndIgnoreCount: Int) extends Product with Serializable

Implements the counting required for O(1) handling of conditionals in Bitcoin Script.

trueCount

The depth of OP_IFs/OP_NOTIFs we've entered on the true condition before the first false.

falseAndIgnoreCount

The depth of OP_IFs/OP_NOTIFs we've entered after and including the first false condition. Every OP_IF/OP_NOTIF adds to trueCount or falseAndIgnoreCount. OP_ELSE has an effect only when falseAndIgnoreCount \== 0 or 1, in which case it moves 1 from trueCount to falseAndIgnoreCount or vice versa. OP_ENDIF subtracts one from either falseAndIgnoreCount or trueCount if falseAndIgnoreCount == 0. trueCount + falseAndIgnoreCount represents the current depth in the conditional tree. falseAndIgnoreCount \== 0 represents whether operations should be executed.

See also

https://github.com/bitcoin/bitcoin/pull/16902

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ConditionalCounter
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new ConditionalCounter(trueCount: Int, falseAndIgnoreCount: Int)

    trueCount

    The depth of OP_IFs/OP_NOTIFs we've entered on the true condition before the first false.

    falseAndIgnoreCount

    The depth of OP_IFs/OP_NOTIFs we've entered after and including the first false condition. Every OP_IF/OP_NOTIF adds to trueCount or falseAndIgnoreCount. OP_ELSE has an effect only when falseAndIgnoreCount \== 0 or 1, in which case it moves 1 from trueCount to falseAndIgnoreCount or vice versa. OP_ENDIF subtracts one from either falseAndIgnoreCount or trueCount if falseAndIgnoreCount == 0. trueCount + falseAndIgnoreCount represents the current depth in the conditional tree. falseAndIgnoreCount \== 0 represents whether operations should be executed.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def addCondition(condition: Boolean): ConditionalCounter

    Should be called for every OP_IF and OP_NOTIF with whether the first (true) or second (false) branch should be taken.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. val falseAndIgnoreCount: Int
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def invertCondition(): ConditionalCounter

    Should be called on for every OP_ELSE.

    Should be called on for every OP_ELSE.

    It is assumed that !noConditionEncountered

  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def noConditionEncountered: Boolean
  15. def noFalseEncountered: Boolean
  16. def noTrueEncountered: Boolean
  17. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. def productElementNames: Iterator[String]
    Definition Classes
    Product
  20. def removeCondition(): ConditionalCounter

    Should be called on for every OP_ENDIF.

    Should be called on for every OP_ENDIF.

    It is assumed that !noConditionEncountered

  21. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  22. def totalDepth: Int
  23. val trueCount: Int
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped