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