// Copyright 2025 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package overlayedchanges

import (
	"github.com/ChainSafe/gossamer/internal/primitives/runtime"
	statemachine "github.com/ChainSafe/gossamer/internal/primitives/state-machine"
)

// A storage changes structure that can be generated by the data collected in [OverlayedChanges].
// This contains all the changes to the storage and transactions to apply theses changes to the
// backend.
type StorageChanges[H runtime.Hash, Hasher runtime.Hasher[H]] struct {
	// All changes to the main storage.
	// A value of nil means that it was deleted.
	MainStorageChanges StorageCollection
	// All changes to the child storages.
	ChildStorageChanges ChildStorageCollection
	// Offchain state changes to write to the offchain database.
	OffchainStorageChanges OffchainChangesCollection
	// A transaction for the backend that contains all changes from
	// main_storage_changes from child_storage_changes and offchain_storage_changes
	Transaction statemachine.BackendTransaction[H, Hasher]
	// The storage root after applying the transaction.
	TransactionStorageRoot H
	// Changes to the transaction index,
	TransactionIndexChanges []IndexOperation
}
