mirror of
https://github.com/luxfi/evmgpu.git
synced 2026-10-30 16:57:11 +00:00
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package message
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/luxfi/ids"
|
|
|
|
"github.com/luxfi/geth/common"
|
|
)
|
|
|
|
var (
|
|
_ Request = BlockRequest{}
|
|
)
|
|
|
|
// BlockRequest is a request to retrieve Parents number of blocks starting from Hash from newest-oldest manner
|
|
type BlockRequest struct {
|
|
Hash common.Hash `serialize:"true"`
|
|
Height uint64 `serialize:"true"`
|
|
Parents uint16 `serialize:"true"`
|
|
}
|
|
|
|
func (b BlockRequest) String() string {
|
|
return fmt.Sprintf(
|
|
"BlockRequest(Hash=%s, Height=%d, Parents=%d)",
|
|
b.Hash, b.Height, b.Parents,
|
|
)
|
|
}
|
|
|
|
func (b BlockRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error) {
|
|
return handler.HandleBlockRequest(ctx, nodeID, requestID, b)
|
|
}
|
|
|
|
// BlockResponse is a response to a BlockRequest
|
|
// Blocks is slice of RLP encoded blocks starting with the block
|
|
// requested in BlockRequest.Hash. The next block is the parent, etc.
|
|
// handler: handlers.BlockRequestHandler
|
|
type BlockResponse struct {
|
|
Blocks [][]byte `serialize:"true"`
|
|
}
|