Skip to content

Commit 4b52a2a

Browse files
author
tac0turtle
committed
cleanup code
1 parent 6d3697a commit 4b52a2a

1 file changed

Lines changed: 12 additions & 22 deletions

File tree

block/manager.go

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -849,37 +849,18 @@ func (m *Manager) execCreateBlock(ctx context.Context, height uint64, lastSignat
849849
// Determine if this is an empty block
850850
isEmpty := batchData.Batch == nil || len(batchData.Transactions) == 0
851851

852-
// Create block data with appropriate transactions
853-
blockData := &types.Data{
854-
Txs: make(types.Txs, 0), // Start with empty transaction list
855-
}
856-
857-
// Only add transactions if this is not an empty block
858-
if !isEmpty {
859-
blockData.Txs = make(types.Txs, len(batchData.Transactions))
860-
for i := range batchData.Transactions {
861-
blockData.Txs[i] = types.Tx(batchData.Transactions[i])
862-
}
863-
}
864-
865852
// Determine AppHash based on execution mode
866853
var appHash []byte
867-
if m.executionMode == coreexecutor.ExecutionModeImmediate && !isEmpty {
868-
869-
rawTxs := make([][]byte, len(blockData.Txs))
870-
// For immediate execution, execute transactions now to get the new state root
871-
for i := range blockData.Txs {
872-
rawTxs[i] = blockData.Txs[i]
873-
}
854+
if m.executionMode == coreexecutor.ExecutionModeImmediate {
874855

875856
// Execute transactions
876-
newStateRoot, _, err := m.exec.ExecuteTxs(ctx, rawTxs, height, batchData.Time, lastState.AppHash)
857+
newStateRoot, _, err := m.exec.ExecuteTxs(ctx, batchData.Transactions, height, batchData.Time, lastState.AppHash)
877858
if err != nil {
878859
return nil, nil, fmt.Errorf("failed to execute transactions for immediate mode: %w", err)
879860
}
880861
appHash = newStateRoot
881862
} else {
882-
// For delayed execution or empty blocks, use the app hash from last state
863+
// For delayed execution, use the app hash from last state
883864
appHash = lastState.AppHash
884865
}
885866

@@ -907,8 +888,17 @@ func (m *Manager) execCreateBlock(ctx context.Context, height uint64, lastSignat
907888
},
908889
}
909890

891+
// Create block data with appropriate transactions
892+
blockData := &types.Data{
893+
Txs: make(types.Txs, 0), // Start with empty transaction list
894+
}
895+
910896
// Set DataHash
911897
if !isEmpty {
898+
blockData.Txs = make(types.Txs, len(batchData.Transactions))
899+
for i := range batchData.Transactions {
900+
blockData.Txs[i] = types.Tx(batchData.Transactions[i])
901+
}
912902
header.DataHash = blockData.DACommitment()
913903
} else {
914904
header.DataHash = dataHashForEmptyTxs

0 commit comments

Comments
 (0)