Skip to content

Commit 95f1339

Browse files
committed
improve godocs and adjust naming
1 parent 6395ddd commit 95f1339

File tree

7 files changed

+17
-10
lines changed

7 files changed

+17
-10
lines changed

fvm/blueprints/scheduled_callback.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func executeCallbackTransaction(
114114
// callback scheduler contract and has the following signature:
115115
// event PendingExecution(id: UInt64, priority: UInt8, executionEffort: UInt64, fees: UFix64, callbackOwner: Address)
116116
func callbackArgsFromEvent(event flow.Event) ([]byte, uint64, error) {
117-
cadenceId, cadenceEffort, err := CallbackDetailsFromEvent(event)
117+
cadenceId, cadenceEffort, err := ParsePendingExecutionEvent(event)
118118
if err != nil {
119119
return nil, 0, err
120120
}
@@ -134,8 +134,9 @@ func callbackArgsFromEvent(event flow.Event) ([]byte, uint64, error) {
134134
return encID, uint64(effort), nil
135135
}
136136

137-
// CallbackDetailsFromEvent decodes the event payload and returns the callback ID and effort.
138-
func CallbackDetailsFromEvent(event flow.Event) (cadence.UInt64, cadence.UInt64, error) {
137+
// ParsePendingExecutionEvent decodes the PendingExecution event payload and returns the scheduled
138+
// transaction's id and effort.
139+
func ParsePendingExecutionEvent(event flow.Event) (cadence.UInt64, cadence.UInt64, error) {
139140
const (
140141
processedCallbackIDFieldName = "id"
141142
processedCallbackEffortFieldName = "executionEffort"

fvm/blueprints/scheduled_callback_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@ func TestIsPendingExecutionEvent(t *testing.T) {
191191
assert.True(t, blueprints.IsPendingExecutionEvent(env, createValidCallbackEvent(t, 1, 100)))
192192
}
193193

194-
func TestCallbackDetailsFromEvent(t *testing.T) {
194+
func TestParsePendingExecutionEvent(t *testing.T) {
195195
t.Parallel()
196196

197197
expectedID := uint64(123)
198198
expectedEffort := uint64(456)
199199
event := createValidCallbackEvent(t, expectedID, expectedEffort)
200200

201-
actualID, actualEffort, err := blueprints.CallbackDetailsFromEvent(event)
201+
actualID, actualEffort, err := blueprints.ParsePendingExecutionEvent(event)
202202
require.NoError(t, err)
203203
assert.Equal(t, expectedID, uint64(actualID))
204204
assert.Equal(t, expectedEffort, uint64(actualEffort))

module/executiondatasync/testutil/fixtures.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"github.com/onflow/flow-go/utils/unittest/fixtures"
1717
)
1818

19+
// TestFixture contains complete random data for testing BlockExecutionData related processing.
20+
// It also includes expected parsed data for easy assertions.
1921
type TestFixture struct {
2022
Block *flow.Block
2123
ExecutionResult *flow.ExecutionResult

module/state_synchronization/indexer/indexer_core.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func collectScheduledTransactions(
321321
// extract the pending execution events and create a mapping from transaction ID to scheduled transaction ID
322322
for i, event := range systemChunkEvents {
323323
if blueprints.IsPendingExecutionEvent(fvmEnv, event) {
324-
id, _, err := blueprints.CallbackDetailsFromEvent(event)
324+
id, _, err := blueprints.ParsePendingExecutionEvent(event)
325325
if err != nil {
326326
return nil, fmt.Errorf("could not get callback details from event %d: %w", i, err)
327327
}

storage/operation/scheduled_transactions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ func RetrieveBlockIDByScheduledTransactionID(r storage.Reader, txID flow.Identif
2222
return RetrieveByKey(r, MakePrefix(codeBlockIDByScheduledTransactionID, txID), blockID)
2323
}
2424

25-
// BatchIndexScheduledTransactionID indexes the scheduled transaction by its scheduled transaction ID and transaction ID.
25+
// BatchIndexScheduledTransactionID indexes the scheduled transaction's transaction ID by its scheduled transaction ID.
2626
//
2727
// No errors are expected during normal operation.
2828
func BatchIndexScheduledTransactionID(w storage.Writer, scheduledTxID uint64, txID flow.Identifier) error {
2929
return UpsertByKey(w, MakePrefix(codeTransactionIDByScheduledTransactionID, scheduledTxID), txID)
3030
}
3131

32-
// BatchIndexScheduledTransactionBlockID indexes the scheduled transaction by its transaction ID and block ID.
32+
// BatchIndexScheduledTransactionBlockID indexes the scheduled transaction's block ID by its transaction ID.
3333
//
3434
// No errors are expected during normal operation.
3535
func BatchIndexScheduledTransactionBlockID(w storage.Writer, txID flow.Identifier, blockID flow.Identifier) error {

storage/store/scheduled_transactions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ import (
1212

1313
var _ storage.ScheduledTransactions = (*ScheduledTransactions)(nil)
1414

15+
// ScheduledTransactions represents persistent storage for scheduled transaction indices.
16+
// Note: no scheduled transactions are stored. Transaction bodies can be generated on-demand using
17+
// the blueprints package. This interface provides access to indices used to lookup the block ID
18+
// that the scheduled transaction was executed in, which allows querying its transaction result.
1519
type ScheduledTransactions struct {
1620
db storage.DB
1721
cacheTxID *Cache[uint64, flow.Identifier]

utils/unittest/fixtures/transaction_result.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (g *TransactionResultGenerator) List(n int, opts ...TransactionResultOption
7474
return list
7575
}
7676

77-
// ForTransactions generates a list of [flow.TransactionResult] for multiple transactions.
77+
// ForTransactions generates a [flow.TransactionResult] for each of the provided transactions.
7878
func (g *TransactionResultGenerator) ForTransactions(transactions []*flow.TransactionBody, opts ...TransactionResultOption) []flow.TransactionResult {
7979
list := make([]flow.TransactionResult, len(transactions))
8080
for i, tx := range transactions {
@@ -148,7 +148,7 @@ func (g *LightTransactionResultGenerator) List(n int, opts ...LightTransactionRe
148148
return list
149149
}
150150

151-
// ForTransactions generates a list of [flow.LightTransactionResult] for multiple transactions.
151+
// ForTransactions generates a [flow.LightTransactionResult] for each of the provided transactions.
152152
func (g *LightTransactionResultGenerator) ForTransactions(transactions []*flow.TransactionBody, opts ...LightTransactionResultOption) []flow.LightTransactionResult {
153153
list := make([]flow.LightTransactionResult, len(transactions))
154154
for i, tx := range transactions {

0 commit comments

Comments
 (0)