github.com/ledgerwatch/erigon-lib@v1.0.0/direct/execution_client.go (about) 1 /* 2 Copyright 2021 Erigon contributors 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package direct 18 19 import ( 20 "context" 21 22 "github.com/ledgerwatch/erigon-lib/gointerfaces/execution" 23 "github.com/ledgerwatch/erigon-lib/gointerfaces/types" 24 "google.golang.org/grpc" 25 "google.golang.org/protobuf/types/known/emptypb" 26 ) 27 28 type ExecutionClientDirect struct { 29 server execution.ExecutionServer 30 } 31 32 func NewExecutionClientDirect(server execution.ExecutionServer) execution.ExecutionClient { 33 return &ExecutionClientDirect{server: server} 34 } 35 36 func (s *ExecutionClientDirect) AssembleBlock(ctx context.Context, in *execution.AssembleBlockRequest, opts ...grpc.CallOption) (*execution.AssembleBlockResponse, error) { 37 return s.server.AssembleBlock(ctx, in) 38 } 39 40 func (s *ExecutionClientDirect) GetBodiesByHashes(ctx context.Context, in *execution.GetBodiesByHashesRequest, opts ...grpc.CallOption) (*execution.GetBodiesBatchResponse, error) { 41 return s.server.GetBodiesByHashes(ctx, in) 42 } 43 44 func (s *ExecutionClientDirect) GetBodiesByRange(ctx context.Context, in *execution.GetBodiesByRangeRequest, opts ...grpc.CallOption) (*execution.GetBodiesBatchResponse, error) { 45 return s.server.GetBodiesByRange(ctx, in) 46 } 47 48 func (s *ExecutionClientDirect) GetAssembledBlock(ctx context.Context, in *execution.GetAssembledBlockRequest, opts ...grpc.CallOption) (*execution.GetAssembledBlockResponse, error) { 49 return s.server.GetAssembledBlock(ctx, in) 50 } 51 52 // Chain Putters. 53 func (s *ExecutionClientDirect) InsertBlocks(ctx context.Context, in *execution.InsertBlocksRequest, opts ...grpc.CallOption) (*execution.InsertionResult, error) { 54 return s.server.InsertBlocks(ctx, in) 55 } 56 57 // Chain Validation and ForkChoice. 58 func (s *ExecutionClientDirect) ValidateChain(ctx context.Context, in *execution.ValidationRequest, opts ...grpc.CallOption) (*execution.ValidationReceipt, error) { 59 return s.server.ValidateChain(ctx, in) 60 61 } 62 63 func (s *ExecutionClientDirect) UpdateForkChoice(ctx context.Context, in *execution.ForkChoice, opts ...grpc.CallOption) (*execution.ForkChoiceReceipt, error) { 64 return s.server.UpdateForkChoice(ctx, in) 65 } 66 67 // Chain Getters. 68 func (s *ExecutionClientDirect) GetHeader(ctx context.Context, in *execution.GetSegmentRequest, opts ...grpc.CallOption) (*execution.GetHeaderResponse, error) { 69 return s.server.GetHeader(ctx, in) 70 } 71 72 func (s *ExecutionClientDirect) CurrentHeader(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*execution.GetHeaderResponse, error) { 73 return s.server.CurrentHeader(ctx, in) 74 } 75 76 func (s *ExecutionClientDirect) GetTD(ctx context.Context, in *execution.GetSegmentRequest, opts ...grpc.CallOption) (*execution.GetTDResponse, error) { 77 return s.server.GetTD(ctx, in) 78 } 79 80 func (s *ExecutionClientDirect) GetBody(ctx context.Context, in *execution.GetSegmentRequest, opts ...grpc.CallOption) (*execution.GetBodyResponse, error) { 81 return s.server.GetBody(ctx, in) 82 } 83 84 func (s *ExecutionClientDirect) IsCanonicalHash(ctx context.Context, in *types.H256, opts ...grpc.CallOption) (*execution.IsCanonicalResponse, error) { 85 return s.server.IsCanonicalHash(ctx, in) 86 } 87 88 func (s *ExecutionClientDirect) GetHeaderHashNumber(ctx context.Context, in *types.H256, opts ...grpc.CallOption) (*execution.GetHeaderHashNumberResponse, error) { 89 return s.server.GetHeaderHashNumber(ctx, in) 90 } 91 92 func (s *ExecutionClientDirect) GetForkChoice(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*execution.ForkChoice, error) { 93 return s.server.GetForkChoice(ctx, in) 94 } 95 96 func (s *ExecutionClientDirect) Ready(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*execution.ReadyResponse, error) { 97 return s.server.Ready(ctx, in) 98 }