Class: XRBP::SHAMap::Node

Inherits:
Object
  • Object
show all
Extended by:
NodeFactory
Defined in:
lib/xrbp/nodestore/shamap/node.rb

Overview

Base Node class, all entries stored in tree structures in nodestore DB inherit from this class

Direct Known Subclasses

InnerNode, TreeNode

Constant Summary collapse

TYPES =
{
  :error          => 0,
  :infer          => 1,
  :transaction_nm => 2,
  :transaction_md => 3,
  :account_state  => 4
}
LEAF_TYPES =
[
  :transaction_nm,
  :transaction_md,
  :account_state
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NodeFactory

make

Constructor Details

#initialize(args = {}) ⇒ Node

Returns a new instance of Node.



26
27
28
29
30
# File 'lib/xrbp/nodestore/shamap/node.rb', line 26

def initialize(args={})
  @hash = args[:hash]
  @type = args[:type]
  @seq  = args[:seq]
end

Instance Attribute Details

#hashObject

Returns the value of attribute hash.



10
11
12
# File 'lib/xrbp/nodestore/shamap/node.rb', line 10

def hash
  @hash
end

Instance Method Details

#inner?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/xrbp/nodestore/shamap/node.rb', line 36

def inner?
  false
end

#leaf?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/xrbp/nodestore/shamap/node.rb', line 32

def leaf?
  LEAF_TYPES.include?(@type)
end

#tree_node?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/xrbp/nodestore/shamap/node.rb', line 40

def tree_node?
  false
end

#update_hashObject



44
45
46
# File 'lib/xrbp/nodestore/shamap/node.rb', line 44

def update_hash
  raise "abstract: must be called on a subclass"
end