github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/fvm/storage/logical/time.go (about) 1 package logical 2 3 import ( 4 "math" 5 ) 6 7 // We will use txIndex as logical time for the purpose of block execution. 8 // 9 // Execution time refers to the transaction's start time. Snapshot time refers 10 // to the time when the snapshot first becomes readable (i.e., the "snapshot 11 // time - 1" transaction committed the snapshot view). Each transaction's 12 // snapshot time must be smaller than or equal to its execution time. 13 // 14 // Normal transaction advances the time clock and must be committed to 15 // DerivedBlockData in monotonically increasing execution time order. 16 // 17 // Snapshot read transaction (aka script) does not advance the time clock. Its 18 // execution and snapshot time must be set to the latest snapshot time (or 19 // EndOfBlockExecutionTime in case the real logical time is unavailable). 20 // 21 // Note that the "real" txIndex range is [0, math.MaxUint32], but we have 22 // expanded the range to support events that are not part of the block 23 // execution. 24 type Time int64 25 26 const ( 27 // All events associated with the parent block is assigned the same value. 28 // 29 // Note that we can assign the time to any value in the range 30 // [math.MinInt64, -1]. 31 ParentBlockTime = Time(-1) 32 33 // All events associated with a child block is assigned the same value. 34 // 35 // Note that we can assign the time to any value in the range 36 // (math.MaxUint32 + 1, math.MaxInt64]. (The +1 is needed for assigning 37 // EndOfBlockExecutionTime a unique value) 38 ChildBlockTime = Time(math.MaxInt64) 39 40 // EndOfBlockExecutionTime is used when the real tx index is unavailable, 41 // such as during script execution. 42 EndOfBlockExecutionTime = ChildBlockTime - 1 43 44 // A normal transaction cannot commit to EndOfBlockExecutionTime. 45 // 46 // Note that we can assign the time to any value in the range 47 // [max.MathUInt32, EndOfBlockExecutionTime) 48 LargestNormalTransactionExecutionTime = EndOfBlockExecutionTime - 1 49 )