package exchain

import (
	"context"
	"github.com/exchain/go-exchain/op-service/eth"
	"github.com/ethereum/go-ethereum/common"
)

// Engine define all api that op-node needed to build a block and process a block.
type Engine interface {
	// NewPayload generate a new execution payload.
	NewPayload(ctx context.Context, params PayloadParams) (*ExecutionPayload, error)
	// ProcessPayload execute a new execute payload that received from other node.
	ProcessPayload(ctx context.Context, payload *ExecutionPayload) error
}

type PayloadParams struct {
	ParentHash   common.Hash
	Timestamp    eth.Uint64Quantity
	Transactions []eth.Data
}

type ExecutionPayload struct {
	ParentHash  common.Hash        `json:"parentHash"`
	BlockHash   common.Hash        `json:"blockHash"`
	BlockNumber eth.Uint64Quantity `json:"blockNumber"`
	Timestamp   eth.Uint64Quantity `json:"timestamp"`

	StateRoot    eth.Bytes32    `json:"stateRoot"`
	ReceiptsRoot eth.Bytes32    `json:"receiptsRoot"`
	ExtraData    eth.BytesMax32 `json:"extraData"`
	Transactions []eth.Data     `json:"transactions"`
}
