Module: Nem::Util

Defined in:
lib/nem/util.rb,
lib/nem/util/convert.rb,
lib/nem/util/ed25519.rb,
lib/nem/util/serializer.rb,
lib/nem/util/deserializer.rb

Defined Under Namespace

Modules: Convert, Deserializer, Ed25519, Serializer

Constant Summary collapse

NEM_EPOCH =
Time.utc(2015, 3, 29, 0, 6, 25, 0)
TESTNET =

-1744830464

0x98000000
MAINNET =

1744830464

0x68000000
MIJIN =
0x60000000

Class Method Summary collapse

Class Method Details

.deadline(seconds = 3600) ⇒ Object



26
27
28
# File 'lib/nem/util.rb', line 26

def self.deadline(seconds = 3600)
  timestamp + seconds
end

.parse_nemtime(nemtime) ⇒ Object



22
23
24
# File 'lib/nem/util.rb', line 22

def self.parse_nemtime(nemtime)
  NEM_EPOCH + nemtime
end

.parse_network(network) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/nem/util.rb', line 13

def self.parse_network(network)
  case network
  when :testnet then TESTNET
  when :mainnet then MAINNET
  when :mijin then MIJIN
    else TESTNET
  end
end

.parse_version(network, version) ⇒ Object



9
10
11
# File 'lib/nem/util.rb', line 9

def self.parse_version(network, version)
  parse_network(network) | version
end

.timestampObject



30
31
32
33
# File 'lib/nem/util.rb', line 30

def self.timestamp
  # escape FAILURE_TIMESTAMP_TOO_FAR_IN_FUTURE
  (Time.now.utc - NEM_EPOCH).to_i - 30
end