Class: Bitcoin::ValidationState
- Inherits:
-
Object
- Object
- Bitcoin::ValidationState
- Defined in:
- lib/bitcoin/validation.rb
Constant Summary collapse
- MODE =
{valid: 0, invlid: 1, error: 2}
Instance Attribute Summary collapse
-
#corruption_possible ⇒ Object
Returns the value of attribute corruption_possible.
-
#debug_message ⇒ Object
Returns the value of attribute debug_message.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#n_dos ⇒ Object
Returns the value of attribute n_dos.
-
#reject_code ⇒ Object
Returns the value of attribute reject_code.
-
#reject_reason ⇒ Object
Returns the value of attribute reject_reason.
Instance Method Summary collapse
- #DoS(level, ret: false, reject_code: 0, reject_reason: '', corruption_in: false, debug_message: '') ⇒ Object
- #error? ⇒ Boolean
-
#initialize ⇒ ValidationState
constructor
A new instance of ValidationState.
- #invalid? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize ⇒ ValidationState
Returns a new instance of ValidationState.
85 86 87 88 89 90 |
# File 'lib/bitcoin/validation.rb', line 85 def initialize @mode = MODE[:valid] @n_dos = 0 @reject_code = 0 @corruption_possible = false end |
Instance Attribute Details
#corruption_possible ⇒ Object
Returns the value of attribute corruption_possible.
82 83 84 |
# File 'lib/bitcoin/validation.rb', line 82 def corruption_possible @corruption_possible end |
#debug_message ⇒ Object
Returns the value of attribute debug_message.
83 84 85 |
# File 'lib/bitcoin/validation.rb', line 83 def @debug_message end |
#mode ⇒ Object
Returns the value of attribute mode.
78 79 80 |
# File 'lib/bitcoin/validation.rb', line 78 def mode @mode end |
#n_dos ⇒ Object
Returns the value of attribute n_dos.
79 80 81 |
# File 'lib/bitcoin/validation.rb', line 79 def n_dos @n_dos end |
#reject_code ⇒ Object
Returns the value of attribute reject_code.
81 82 83 |
# File 'lib/bitcoin/validation.rb', line 81 def reject_code @reject_code end |
#reject_reason ⇒ Object
Returns the value of attribute reject_reason.
80 81 82 |
# File 'lib/bitcoin/validation.rb', line 80 def reject_reason @reject_reason end |
Instance Method Details
#DoS(level, ret: false, reject_code: 0, reject_reason: '', corruption_in: false, debug_message: '') ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/bitcoin/validation.rb', line 92 def DoS(level, ret: false, reject_code: 0, reject_reason: '', corruption_in: false, debug_message: '') @reject_code = reject_code @reject_reason = reject_reason @corruption_possible = corruption_in @debug_message = return ret if mode == MODE[:error] @n_dos += level @mode = MODE[:invalid] ret end |
#error? ⇒ Boolean
111 112 113 |
# File 'lib/bitcoin/validation.rb', line 111 def error? mode == MODE[:error] end |
#invalid? ⇒ Boolean
107 108 109 |
# File 'lib/bitcoin/validation.rb', line 107 def invalid? mode == MODE[:invalid] end |
#valid? ⇒ Boolean
103 104 105 |
# File 'lib/bitcoin/validation.rb', line 103 def valid? mode == MODE[:valid] end |