Skip to content

Commit

Permalink
Add arguments type check
Browse files Browse the repository at this point in the history
  • Loading branch information
azuchi committed Aug 9, 2024
1 parent 46f0f36 commit 0b62492
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/bitcoin/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ class Block
attr_accessor :header
attr_accessor :transactions

# Constructor
# @param [Bitcoin::BlockHeader] header
# @param [Array] transactions An array of transaction.
# @raise [ArgumentError]
def initialize(header, transactions = [])
raise ArgumentError, "header must be Bitcoin::BlockHeader." unless header.is_a?(Bitcoin::BlockHeader)
raise ArgumentError, "transactions must be an Array." unless transactions.is_a?(Array)
@header = header
@transactions = transactions
end
Expand Down

0 comments on commit 0b62492

Please sign in to comment.