Files
zeekayandHanzo Dev b1cc108c9f gofmt
Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 01:51:51 -07:00

70 lines
1.6 KiB
Go

// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package executor
import (
"context"
"github.com/luxfi/ids"
"github.com/luxfi/log"
"github.com/luxfi/node/vms/components/verify"
"github.com/luxfi/node/vms/xvm/config"
"github.com/luxfi/node/vms/xvm/fxs"
"github.com/luxfi/node/vms/xvm/txs"
"github.com/luxfi/runtime"
)
type Backend struct {
Ctx context.Context
Runtime *runtime.Runtime
Config *config.Config
Fxs []*fxs.ParsedFx
FxIndex *txs.FxIndex
// Note: FeeAssetID may be different than ctx.UTXOAssetID if this XVM is
// running in a chain.
FeeAssetID ids.ID
Bootstrapped bool
// Chain IDs for cross-chain operations
XChainID ids.ID
CChainID ids.ID
// Logger for this backend
Log log.Logger
// SharedMemory provides cross-chain atomic operations
SharedMemory SharedMemory
}
// SharedMemory interface for cross-chain operations
type SharedMemory interface {
Get(peerChainID ids.ID, keys [][]byte) ([][]byte, error)
Apply(requests map[ids.ID]interface{}, batch ...interface{}) error
}
// ToChainContext creates a verify.ChainContext from this backend
func (b *Backend) ToChainContext() *verify.ChainContext {
var (
chainID ids.ID
netID ids.ID
vs runtime.ValidatorState
)
if b.Runtime != nil {
chainID = b.Runtime.ChainID
if runtimeVS, ok := b.Runtime.ValidatorState.(runtime.ValidatorState); ok {
vs = runtimeVS
if resolvedNetID, err := runtimeVS.GetNetworkID(chainID); err == nil {
netID = resolvedNetID
}
}
}
return &verify.ChainContext{
ChainID: chainID,
NetID: netID,
ValidatorState: vs,
}
}