Class: Ethereum::SPV::Proof

Inherits:
Object show all
Defined in:
lib/ethereum/spv/proof.rb

Direct Known Subclasses

ProofConstructor, ProofVerifier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nodes: Set.new, exempts: []) ⇒ Proof

Returns a new instance of Proof.



11
12
13
14
# File 'lib/ethereum/spv/proof.rb', line 11

def initialize(nodes: Set.new, exempts: [])
  @nodes = nodes
  @exempts = exempts
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



9
10
11
# File 'lib/ethereum/spv/proof.rb', line 9

def nodes
  @nodes
end

Instance Method Details

#add_exempt(node) ⇒ Object



25
26
27
# File 'lib/ethereum/spv/proof.rb', line 25

def add_exempt(node)
  exempts.add FastRLP.encode(node)
end

#add_node(node) ⇒ Object



20
21
22
23
# File 'lib/ethereum/spv/proof.rb', line 20

def add_node(node)
  node = FastRLP.encode node
  nodes.add(node) unless exempts.include?(node)
end

#decoded_nodesObject



16
17
18
# File 'lib/ethereum/spv/proof.rb', line 16

def decoded_nodes
  nodes.map {|n| RLP.decode(n) }
end