Merge pull request #7 from status-im/EthTime
Use separate EthTime type for timestamps
This commit is contained in:
commit
20a9c4903d
|
@ -38,7 +38,7 @@ type
|
||||||
nonce*: string
|
nonce*: string
|
||||||
mixHash*: string
|
mixHash*: string
|
||||||
extraData*: string
|
extraData*: string
|
||||||
timestamp*: int
|
timestamp*: EthTime
|
||||||
stateRoot*: string
|
stateRoot*: string
|
||||||
|
|
||||||
FundedAddress* = ref object
|
FundedAddress* = ref object
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
ttmath, math, strutils, tables, utils/padding, rlp
|
ttmath, math, strutils, tables, utils/padding, rlp, times
|
||||||
|
|
||||||
# rlpFields UInt256, table
|
# rlpFields UInt256, table
|
||||||
|
|
||||||
type
|
type
|
||||||
TypeHint* {.pure.} = enum UInt256, Bytes, Any
|
TypeHint* {.pure.} = enum UInt256, Bytes, Any
|
||||||
|
EthTime* = Time
|
||||||
|
|
||||||
|
|
||||||
#Bytes* = seq[byte]
|
#Bytes* = seq[byte]
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
import
|
import
|
||||||
../constants, ../errors, ../computation, ../vm_state, ../types, .. / vm / [stack]
|
../constants, ../errors, ../computation, ../vm_state, ../types, .. / vm / [stack], ttmath
|
||||||
|
|
||||||
{.this: computation.}
|
{.this: computation.}
|
||||||
{.experimental.}
|
{.experimental.}
|
||||||
|
@ -23,7 +23,9 @@ proc coinbase*(computation) =
|
||||||
stack.push(vmState.coinbase)
|
stack.push(vmState.coinbase)
|
||||||
|
|
||||||
proc timestamp*(computation) =
|
proc timestamp*(computation) =
|
||||||
stack.push(vmState.timestamp.u256)
|
# TODO: EthTime is an alias of Time, which is a distinct int64 so can't use u256(int64)
|
||||||
|
# This may have implications for different platforms.
|
||||||
|
stack.push(vmState.timestamp.uint64.u256)
|
||||||
|
|
||||||
proc number*(computation) =
|
proc number*(computation) =
|
||||||
stack.push(vmState.blockNumber)
|
stack.push(vmState.blockNumber)
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
import ../constants, ttmath, strformat, times, ../validation
|
import ../constants, ttmath, strformat, times, ../validation
|
||||||
|
|
||||||
type
|
type
|
||||||
EthTime = Time
|
|
||||||
Header* = ref object
|
Header* = ref object
|
||||||
timestamp*: EthTime
|
timestamp*: EthTime
|
||||||
difficulty*: UInt256
|
difficulty*: UInt256
|
||||||
|
|
|
@ -13,4 +13,3 @@ template keccak*(value: string): string =
|
||||||
|
|
||||||
template keccak*(value: cstring): string =
|
template keccak*(value: cstring): string =
|
||||||
($value).keccak
|
($value).keccak
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ method blockhash*(vmState: BaseVMState): string =
|
||||||
method coinbase*(vmState: BaseVMState): string =
|
method coinbase*(vmState: BaseVMState): string =
|
||||||
vmState.blockHeader.coinbase
|
vmState.blockHeader.coinbase
|
||||||
|
|
||||||
method timestamp*(vmState: BaseVMState): int =
|
method timestamp*(vmState: BaseVMState): EthTime =
|
||||||
vmState.blockHeader.timestamp
|
vmState.blockHeader.timestamp
|
||||||
|
|
||||||
method blockNumber*(vmState: BaseVMState): UInt256 =
|
method blockNumber*(vmState: BaseVMState): UInt256 =
|
||||||
|
|
Loading…
Reference in New Issue