github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/engine/access/apiproxy/access_api_proxy.go (about) 1 package apiproxy 2 3 import ( 4 "context" 5 6 "github.com/onflow/flow/protobuf/go/flow/access" 7 "github.com/rs/zerolog" 8 "google.golang.org/grpc/codes" 9 "google.golang.org/grpc/status" 10 11 accessflow "github.com/onflow/flow-go/access" 12 "github.com/onflow/flow-go/engine/access/rpc/connection" 13 "github.com/onflow/flow-go/engine/common/grpc/forwarder" 14 "github.com/onflow/flow-go/model/flow" 15 "github.com/onflow/flow-go/module/metrics" 16 ) 17 18 const ( 19 LocalApiService = "local" 20 UpstreamApiService = "upstream" 21 ) 22 23 // FlowAccessAPIRouter is a structure that represents the routing proxy algorithm. 24 // It splits requests between a local and a remote API service. 25 type FlowAccessAPIRouter struct { 26 logger zerolog.Logger 27 metrics *metrics.ObserverCollector 28 upstream *FlowAccessAPIForwarder 29 local *accessflow.Handler 30 useIndex bool 31 } 32 33 type Params struct { 34 Log zerolog.Logger 35 Metrics *metrics.ObserverCollector 36 Upstream *FlowAccessAPIForwarder 37 Local *accessflow.Handler 38 UseIndex bool 39 } 40 41 // NewFlowAccessAPIRouter creates FlowAccessAPIRouter instance 42 func NewFlowAccessAPIRouter(params Params) *FlowAccessAPIRouter { 43 h := &FlowAccessAPIRouter{ 44 logger: params.Log, 45 metrics: params.Metrics, 46 upstream: params.Upstream, 47 local: params.Local, 48 useIndex: params.UseIndex, 49 } 50 51 return h 52 } 53 54 func (h *FlowAccessAPIRouter) log(handler, rpc string, err error) { 55 code := status.Code(err) 56 h.metrics.RecordRPC(handler, rpc, code) 57 58 logger := h.logger.With(). 59 Str("handler", handler). 60 Str("grpc_method", rpc). 61 Str("grpc_code", code.String()). 62 Logger() 63 64 if err != nil { 65 logger.Error().Err(err).Msg("request failed") 66 return 67 } 68 69 logger.Info().Msg("request succeeded") 70 } 71 72 // Ping pings the service. It is special in the sense that it responds successful, 73 // only if all underlying services are ready. 74 func (h *FlowAccessAPIRouter) Ping(context context.Context, req *access.PingRequest) (*access.PingResponse, error) { 75 h.log(LocalApiService, "Ping", nil) 76 return &access.PingResponse{}, nil 77 } 78 79 func (h *FlowAccessAPIRouter) GetNodeVersionInfo(ctx context.Context, request *access.GetNodeVersionInfoRequest) (*access.GetNodeVersionInfoResponse, error) { 80 res, err := h.local.GetNodeVersionInfo(ctx, request) 81 h.log(LocalApiService, "GetNodeVersionInfo", err) 82 return res, err 83 } 84 85 func (h *FlowAccessAPIRouter) GetLatestBlockHeader(context context.Context, req *access.GetLatestBlockHeaderRequest) (*access.BlockHeaderResponse, error) { 86 res, err := h.local.GetLatestBlockHeader(context, req) 87 h.log(LocalApiService, "GetLatestBlockHeader", err) 88 return res, err 89 } 90 91 func (h *FlowAccessAPIRouter) GetBlockHeaderByID(context context.Context, req *access.GetBlockHeaderByIDRequest) (*access.BlockHeaderResponse, error) { 92 res, err := h.local.GetBlockHeaderByID(context, req) 93 h.log(LocalApiService, "GetBlockHeaderByID", err) 94 return res, err 95 } 96 97 func (h *FlowAccessAPIRouter) GetBlockHeaderByHeight(context context.Context, req *access.GetBlockHeaderByHeightRequest) (*access.BlockHeaderResponse, error) { 98 res, err := h.local.GetBlockHeaderByHeight(context, req) 99 h.log(LocalApiService, "GetBlockHeaderByHeight", err) 100 return res, err 101 } 102 103 func (h *FlowAccessAPIRouter) GetLatestBlock(context context.Context, req *access.GetLatestBlockRequest) (*access.BlockResponse, error) { 104 res, err := h.local.GetLatestBlock(context, req) 105 h.log(LocalApiService, "GetLatestBlock", err) 106 return res, err 107 } 108 109 func (h *FlowAccessAPIRouter) GetBlockByID(context context.Context, req *access.GetBlockByIDRequest) (*access.BlockResponse, error) { 110 res, err := h.local.GetBlockByID(context, req) 111 h.log(LocalApiService, "GetBlockByID", err) 112 return res, err 113 } 114 115 func (h *FlowAccessAPIRouter) GetBlockByHeight(context context.Context, req *access.GetBlockByHeightRequest) (*access.BlockResponse, error) { 116 res, err := h.local.GetBlockByHeight(context, req) 117 h.log(LocalApiService, "GetBlockByHeight", err) 118 return res, err 119 } 120 121 func (h *FlowAccessAPIRouter) GetCollectionByID(context context.Context, req *access.GetCollectionByIDRequest) (*access.CollectionResponse, error) { 122 if h.useIndex { 123 res, err := h.local.GetCollectionByID(context, req) 124 h.log(LocalApiService, "GetCollectionByID", err) 125 return res, err 126 } 127 128 res, err := h.upstream.GetCollectionByID(context, req) 129 h.log(UpstreamApiService, "GetCollectionByID", err) 130 return res, err 131 } 132 133 func (h *FlowAccessAPIRouter) SendTransaction(context context.Context, req *access.SendTransactionRequest) (*access.SendTransactionResponse, error) { 134 res, err := h.upstream.SendTransaction(context, req) 135 h.log(UpstreamApiService, "SendTransaction", err) 136 return res, err 137 } 138 139 func (h *FlowAccessAPIRouter) GetTransaction(context context.Context, req *access.GetTransactionRequest) (*access.TransactionResponse, error) { 140 if h.useIndex { 141 res, err := h.local.GetTransaction(context, req) 142 h.log(LocalApiService, "GetTransaction", err) 143 return res, err 144 } 145 146 res, err := h.upstream.GetTransaction(context, req) 147 h.log(UpstreamApiService, "GetTransaction", err) 148 return res, err 149 } 150 151 func (h *FlowAccessAPIRouter) GetTransactionResult(context context.Context, req *access.GetTransactionRequest) (*access.TransactionResultResponse, error) { 152 //TODO: add implementation for transaction error message before adding local impl 153 154 res, err := h.upstream.GetTransactionResult(context, req) 155 h.log(UpstreamApiService, "GetTransactionResult", err) 156 return res, err 157 } 158 159 func (h *FlowAccessAPIRouter) GetTransactionResultsByBlockID(context context.Context, req *access.GetTransactionsByBlockIDRequest) (*access.TransactionResultsResponse, error) { 160 //TODO: add implementation for transaction error message before adding local impl 161 162 res, err := h.upstream.GetTransactionResultsByBlockID(context, req) 163 h.log(UpstreamApiService, "GetTransactionResultsByBlockID", err) 164 return res, err 165 } 166 167 func (h *FlowAccessAPIRouter) GetTransactionsByBlockID(context context.Context, req *access.GetTransactionsByBlockIDRequest) (*access.TransactionsResponse, error) { 168 if h.useIndex { 169 res, err := h.local.GetTransactionsByBlockID(context, req) 170 h.log(LocalApiService, "GetTransactionsByBlockID", err) 171 return res, err 172 } 173 174 res, err := h.upstream.GetTransactionsByBlockID(context, req) 175 h.log(UpstreamApiService, "GetTransactionsByBlockID", err) 176 return res, err 177 } 178 179 func (h *FlowAccessAPIRouter) GetTransactionResultByIndex(context context.Context, req *access.GetTransactionByIndexRequest) (*access.TransactionResultResponse, error) { 180 //TODO: add implementation for transaction error message before adding local impl 181 182 res, err := h.upstream.GetTransactionResultByIndex(context, req) 183 h.log(UpstreamApiService, "GetTransactionResultByIndex", err) 184 return res, err 185 } 186 187 func (h *FlowAccessAPIRouter) GetSystemTransaction(context context.Context, req *access.GetSystemTransactionRequest) (*access.TransactionResponse, error) { 188 if h.useIndex { 189 res, err := h.local.GetSystemTransaction(context, req) 190 h.log(LocalApiService, "GetSystemTransaction", err) 191 return res, err 192 } 193 194 res, err := h.upstream.GetSystemTransaction(context, req) 195 h.log(UpstreamApiService, "GetSystemTransaction", err) 196 return res, err 197 } 198 199 func (h *FlowAccessAPIRouter) GetSystemTransactionResult(context context.Context, req *access.GetSystemTransactionResultRequest) (*access.TransactionResultResponse, error) { 200 res, err := h.upstream.GetSystemTransactionResult(context, req) 201 h.log(UpstreamApiService, "GetSystemTransactionResult", err) 202 return res, err 203 } 204 205 func (h *FlowAccessAPIRouter) GetAccount(context context.Context, req *access.GetAccountRequest) (*access.GetAccountResponse, error) { 206 if h.useIndex { 207 res, err := h.local.GetAccount(context, req) 208 h.log(LocalApiService, "GetAccount", err) 209 return res, err 210 } 211 212 res, err := h.upstream.GetAccount(context, req) 213 h.log(UpstreamApiService, "GetAccount", err) 214 return res, err 215 } 216 217 func (h *FlowAccessAPIRouter) GetAccountAtLatestBlock(context context.Context, req *access.GetAccountAtLatestBlockRequest) (*access.AccountResponse, error) { 218 if h.useIndex { 219 res, err := h.local.GetAccountAtLatestBlock(context, req) 220 h.log(LocalApiService, "GetAccountAtLatestBlock", err) 221 return res, err 222 } 223 224 res, err := h.upstream.GetAccountAtLatestBlock(context, req) 225 h.log(UpstreamApiService, "GetAccountAtLatestBlock", err) 226 return res, err 227 } 228 229 func (h *FlowAccessAPIRouter) GetAccountAtBlockHeight(context context.Context, req *access.GetAccountAtBlockHeightRequest) (*access.AccountResponse, error) { 230 if h.useIndex { 231 res, err := h.local.GetAccountAtBlockHeight(context, req) 232 h.log(LocalApiService, "GetAccountAtBlockHeight", err) 233 return res, err 234 } 235 236 res, err := h.upstream.GetAccountAtBlockHeight(context, req) 237 h.log(UpstreamApiService, "GetAccountAtBlockHeight", err) 238 return res, err 239 } 240 241 func (h *FlowAccessAPIRouter) ExecuteScriptAtLatestBlock(context context.Context, req *access.ExecuteScriptAtLatestBlockRequest) (*access.ExecuteScriptResponse, error) { 242 if h.useIndex { 243 res, err := h.local.ExecuteScriptAtLatestBlock(context, req) 244 h.log(LocalApiService, "ExecuteScriptAtLatestBlock", err) 245 return res, err 246 } 247 248 res, err := h.upstream.ExecuteScriptAtLatestBlock(context, req) 249 h.log(UpstreamApiService, "ExecuteScriptAtLatestBlock", err) 250 return res, err 251 } 252 253 func (h *FlowAccessAPIRouter) ExecuteScriptAtBlockID(context context.Context, req *access.ExecuteScriptAtBlockIDRequest) (*access.ExecuteScriptResponse, error) { 254 if h.useIndex { 255 res, err := h.local.ExecuteScriptAtBlockID(context, req) 256 h.log(LocalApiService, "ExecuteScriptAtBlockID", err) 257 return res, err 258 } 259 260 res, err := h.upstream.ExecuteScriptAtBlockID(context, req) 261 h.log(UpstreamApiService, "ExecuteScriptAtBlockID", err) 262 return res, err 263 } 264 265 func (h *FlowAccessAPIRouter) ExecuteScriptAtBlockHeight(context context.Context, req *access.ExecuteScriptAtBlockHeightRequest) (*access.ExecuteScriptResponse, error) { 266 if h.useIndex { 267 res, err := h.local.ExecuteScriptAtBlockHeight(context, req) 268 h.log(LocalApiService, "ExecuteScriptAtBlockHeight", err) 269 return res, err 270 } 271 272 res, err := h.upstream.ExecuteScriptAtBlockHeight(context, req) 273 h.log(UpstreamApiService, "ExecuteScriptAtBlockHeight", err) 274 return res, err 275 } 276 277 func (h *FlowAccessAPIRouter) GetEventsForHeightRange(context context.Context, req *access.GetEventsForHeightRangeRequest) (*access.EventsResponse, error) { 278 if h.useIndex { 279 res, err := h.local.GetEventsForHeightRange(context, req) 280 h.log(LocalApiService, "GetEventsForHeightRange", err) 281 return res, err 282 } 283 284 res, err := h.upstream.GetEventsForHeightRange(context, req) 285 h.log(UpstreamApiService, "GetEventsForHeightRange", err) 286 return res, err 287 } 288 289 func (h *FlowAccessAPIRouter) GetEventsForBlockIDs(context context.Context, req *access.GetEventsForBlockIDsRequest) (*access.EventsResponse, error) { 290 if h.useIndex { 291 res, err := h.local.GetEventsForBlockIDs(context, req) 292 h.log(LocalApiService, "GetEventsForBlockIDs", err) 293 return res, err 294 } 295 296 res, err := h.upstream.GetEventsForBlockIDs(context, req) 297 h.log(UpstreamApiService, "GetEventsForBlockIDs", err) 298 return res, err 299 } 300 301 func (h *FlowAccessAPIRouter) GetNetworkParameters(context context.Context, req *access.GetNetworkParametersRequest) (*access.GetNetworkParametersResponse, error) { 302 res, err := h.local.GetNetworkParameters(context, req) 303 h.log(LocalApiService, "GetNetworkParameters", err) 304 return res, err 305 } 306 307 func (h *FlowAccessAPIRouter) GetLatestProtocolStateSnapshot(context context.Context, req *access.GetLatestProtocolStateSnapshotRequest) (*access.ProtocolStateSnapshotResponse, error) { 308 res, err := h.local.GetLatestProtocolStateSnapshot(context, req) 309 h.log(LocalApiService, "GetLatestProtocolStateSnapshot", err) 310 return res, err 311 } 312 313 func (h *FlowAccessAPIRouter) GetProtocolStateSnapshotByBlockID(context context.Context, req *access.GetProtocolStateSnapshotByBlockIDRequest) (*access.ProtocolStateSnapshotResponse, error) { 314 res, err := h.local.GetProtocolStateSnapshotByBlockID(context, req) 315 h.log(LocalApiService, "GetProtocolStateSnapshotByBlockID", err) 316 return res, err 317 } 318 319 func (h *FlowAccessAPIRouter) GetProtocolStateSnapshotByHeight(context context.Context, req *access.GetProtocolStateSnapshotByHeightRequest) (*access.ProtocolStateSnapshotResponse, error) { 320 res, err := h.local.GetProtocolStateSnapshotByHeight(context, req) 321 h.log(LocalApiService, "GetProtocolStateSnapshotByHeight", err) 322 return res, err 323 } 324 325 func (h *FlowAccessAPIRouter) GetExecutionResultForBlockID(context context.Context, req *access.GetExecutionResultForBlockIDRequest) (*access.ExecutionResultForBlockIDResponse, error) { 326 res, err := h.upstream.GetExecutionResultForBlockID(context, req) 327 h.log(UpstreamApiService, "GetExecutionResultForBlockID", err) 328 return res, err 329 } 330 331 func (h *FlowAccessAPIRouter) GetExecutionResultByID(context context.Context, req *access.GetExecutionResultByIDRequest) (*access.ExecutionResultByIDResponse, error) { 332 if h.useIndex { 333 res, err := h.local.GetExecutionResultByID(context, req) 334 h.log(LocalApiService, "GetExecutionResultByID", err) 335 return res, err 336 } 337 338 res, err := h.upstream.GetExecutionResultByID(context, req) 339 h.log(UpstreamApiService, "GetExecutionResultByID", err) 340 return res, err 341 } 342 343 func (h *FlowAccessAPIRouter) SubscribeBlocksFromStartBlockID(req *access.SubscribeBlocksFromStartBlockIDRequest, server access.AccessAPI_SubscribeBlocksFromStartBlockIDServer) error { 344 err := h.local.SubscribeBlocksFromStartBlockID(req, server) 345 h.log(LocalApiService, "SubscribeBlocksFromStartBlockID", err) 346 return err 347 } 348 349 func (h *FlowAccessAPIRouter) SubscribeBlocksFromStartHeight(req *access.SubscribeBlocksFromStartHeightRequest, server access.AccessAPI_SubscribeBlocksFromStartHeightServer) error { 350 err := h.local.SubscribeBlocksFromStartHeight(req, server) 351 h.log(LocalApiService, "SubscribeBlocksFromStartHeight", err) 352 return err 353 } 354 355 func (h *FlowAccessAPIRouter) SubscribeBlocksFromLatest(req *access.SubscribeBlocksFromLatestRequest, server access.AccessAPI_SubscribeBlocksFromLatestServer) error { 356 err := h.local.SubscribeBlocksFromLatest(req, server) 357 h.log(LocalApiService, "SubscribeBlocksFromLatest", err) 358 return err 359 } 360 361 func (h *FlowAccessAPIRouter) SubscribeBlockHeadersFromStartBlockID(req *access.SubscribeBlockHeadersFromStartBlockIDRequest, server access.AccessAPI_SubscribeBlockHeadersFromStartBlockIDServer) error { 362 err := h.local.SubscribeBlockHeadersFromStartBlockID(req, server) 363 h.log(LocalApiService, "SubscribeBlockHeadersFromStartBlockID", err) 364 return err 365 } 366 367 func (h *FlowAccessAPIRouter) SubscribeBlockHeadersFromStartHeight(req *access.SubscribeBlockHeadersFromStartHeightRequest, server access.AccessAPI_SubscribeBlockHeadersFromStartHeightServer) error { 368 err := h.local.SubscribeBlockHeadersFromStartHeight(req, server) 369 h.log(LocalApiService, "SubscribeBlockHeadersFromStartHeight", err) 370 return err 371 } 372 373 func (h *FlowAccessAPIRouter) SubscribeBlockHeadersFromLatest(req *access.SubscribeBlockHeadersFromLatestRequest, server access.AccessAPI_SubscribeBlockHeadersFromLatestServer) error { 374 err := h.local.SubscribeBlockHeadersFromLatest(req, server) 375 h.log(LocalApiService, "SubscribeBlockHeadersFromLatest", err) 376 return err 377 } 378 379 func (h *FlowAccessAPIRouter) SubscribeBlockDigestsFromStartBlockID(req *access.SubscribeBlockDigestsFromStartBlockIDRequest, server access.AccessAPI_SubscribeBlockDigestsFromStartBlockIDServer) error { 380 err := h.local.SubscribeBlockDigestsFromStartBlockID(req, server) 381 h.log(LocalApiService, "SubscribeBlockDigestsFromStartBlockID", err) 382 return err 383 } 384 385 func (h *FlowAccessAPIRouter) SubscribeBlockDigestsFromStartHeight(req *access.SubscribeBlockDigestsFromStartHeightRequest, server access.AccessAPI_SubscribeBlockDigestsFromStartHeightServer) error { 386 err := h.local.SubscribeBlockDigestsFromStartHeight(req, server) 387 h.log(LocalApiService, "SubscribeBlockDigestsFromStartHeight", err) 388 return err 389 } 390 391 func (h *FlowAccessAPIRouter) SubscribeBlockDigestsFromLatest(req *access.SubscribeBlockDigestsFromLatestRequest, server access.AccessAPI_SubscribeBlockDigestsFromLatestServer) error { 392 err := h.local.SubscribeBlockDigestsFromLatest(req, server) 393 h.log(LocalApiService, "SubscribeBlockDigestsFromLatest", err) 394 return err 395 } 396 397 func (h *FlowAccessAPIRouter) SendAndSubscribeTransactionStatuses(req *access.SendAndSubscribeTransactionStatusesRequest, server access.AccessAPI_SendAndSubscribeTransactionStatusesServer) error { 398 //SendAndSubscribeTransactionStatuses is not implemented for observer yet 399 return status.Errorf(codes.Unimplemented, "method SendAndSubscribeTransactionStatuses not implemented") 400 } 401 402 // FlowAccessAPIForwarder forwards all requests to a set of upstream access nodes or observers 403 type FlowAccessAPIForwarder struct { 404 *forwarder.Forwarder 405 } 406 407 func NewFlowAccessAPIForwarder(identities flow.IdentitySkeletonList, connectionFactory connection.ConnectionFactory) (*FlowAccessAPIForwarder, error) { 408 forwarder, err := forwarder.NewForwarder(identities, connectionFactory) 409 if err != nil { 410 return nil, err 411 } 412 413 return &FlowAccessAPIForwarder{ 414 Forwarder: forwarder, 415 }, nil 416 } 417 418 // Ping pings the service. It is special in the sense that it responds successful, 419 // only if all underlying services are ready. 420 func (h *FlowAccessAPIForwarder) Ping(context context.Context, req *access.PingRequest) (*access.PingResponse, error) { 421 // This is a passthrough request 422 upstream, closer, err := h.FaultTolerantClient() 423 if err != nil { 424 return nil, err 425 } 426 defer closer.Close() 427 return upstream.Ping(context, req) 428 } 429 430 func (h *FlowAccessAPIForwarder) GetNodeVersionInfo(context context.Context, req *access.GetNodeVersionInfoRequest) (*access.GetNodeVersionInfoResponse, error) { 431 // This is a passthrough request 432 upstream, closer, err := h.FaultTolerantClient() 433 if err != nil { 434 return nil, err 435 } 436 defer closer.Close() 437 return upstream.GetNodeVersionInfo(context, req) 438 } 439 440 func (h *FlowAccessAPIForwarder) GetLatestBlockHeader(context context.Context, req *access.GetLatestBlockHeaderRequest) (*access.BlockHeaderResponse, error) { 441 // This is a passthrough request 442 upstream, closer, err := h.FaultTolerantClient() 443 if err != nil { 444 return nil, err 445 } 446 defer closer.Close() 447 return upstream.GetLatestBlockHeader(context, req) 448 } 449 450 func (h *FlowAccessAPIForwarder) GetBlockHeaderByID(context context.Context, req *access.GetBlockHeaderByIDRequest) (*access.BlockHeaderResponse, error) { 451 // This is a passthrough request 452 upstream, closer, err := h.FaultTolerantClient() 453 if err != nil { 454 return nil, err 455 } 456 defer closer.Close() 457 return upstream.GetBlockHeaderByID(context, req) 458 } 459 460 func (h *FlowAccessAPIForwarder) GetBlockHeaderByHeight(context context.Context, req *access.GetBlockHeaderByHeightRequest) (*access.BlockHeaderResponse, error) { 461 // This is a passthrough request 462 upstream, closer, err := h.FaultTolerantClient() 463 if err != nil { 464 return nil, err 465 } 466 defer closer.Close() 467 return upstream.GetBlockHeaderByHeight(context, req) 468 } 469 470 func (h *FlowAccessAPIForwarder) GetLatestBlock(context context.Context, req *access.GetLatestBlockRequest) (*access.BlockResponse, error) { 471 // This is a passthrough request 472 upstream, closer, err := h.FaultTolerantClient() 473 if err != nil { 474 return nil, err 475 } 476 defer closer.Close() 477 return upstream.GetLatestBlock(context, req) 478 } 479 480 func (h *FlowAccessAPIForwarder) GetBlockByID(context context.Context, req *access.GetBlockByIDRequest) (*access.BlockResponse, error) { 481 // This is a passthrough request 482 upstream, closer, err := h.FaultTolerantClient() 483 if err != nil { 484 return nil, err 485 } 486 defer closer.Close() 487 return upstream.GetBlockByID(context, req) 488 } 489 490 func (h *FlowAccessAPIForwarder) GetBlockByHeight(context context.Context, req *access.GetBlockByHeightRequest) (*access.BlockResponse, error) { 491 // This is a passthrough request 492 upstream, closer, err := h.FaultTolerantClient() 493 if err != nil { 494 return nil, err 495 } 496 defer closer.Close() 497 return upstream.GetBlockByHeight(context, req) 498 } 499 500 func (h *FlowAccessAPIForwarder) GetCollectionByID(context context.Context, req *access.GetCollectionByIDRequest) (*access.CollectionResponse, error) { 501 // This is a passthrough request 502 upstream, closer, err := h.FaultTolerantClient() 503 if err != nil { 504 return nil, err 505 } 506 defer closer.Close() 507 return upstream.GetCollectionByID(context, req) 508 } 509 510 func (h *FlowAccessAPIForwarder) SendTransaction(context context.Context, req *access.SendTransactionRequest) (*access.SendTransactionResponse, error) { 511 // This is a passthrough request 512 upstream, closer, err := h.FaultTolerantClient() 513 if err != nil { 514 return nil, err 515 } 516 defer closer.Close() 517 return upstream.SendTransaction(context, req) 518 } 519 520 func (h *FlowAccessAPIForwarder) GetTransaction(context context.Context, req *access.GetTransactionRequest) (*access.TransactionResponse, error) { 521 // This is a passthrough request 522 upstream, closer, err := h.FaultTolerantClient() 523 if err != nil { 524 return nil, err 525 } 526 defer closer.Close() 527 return upstream.GetTransaction(context, req) 528 } 529 530 func (h *FlowAccessAPIForwarder) GetTransactionResult(context context.Context, req *access.GetTransactionRequest) (*access.TransactionResultResponse, error) { 531 // This is a passthrough request 532 upstream, closer, err := h.FaultTolerantClient() 533 if err != nil { 534 return nil, err 535 } 536 defer closer.Close() 537 return upstream.GetTransactionResult(context, req) 538 } 539 540 func (h *FlowAccessAPIForwarder) GetSystemTransaction(context context.Context, req *access.GetSystemTransactionRequest) (*access.TransactionResponse, error) { 541 // This is a passthrough request 542 upstream, closer, err := h.FaultTolerantClient() 543 if err != nil { 544 return nil, err 545 } 546 defer closer.Close() 547 return upstream.GetSystemTransaction(context, req) 548 } 549 550 func (h *FlowAccessAPIForwarder) GetSystemTransactionResult(context context.Context, req *access.GetSystemTransactionResultRequest) (*access.TransactionResultResponse, error) { 551 // This is a passthrough request 552 upstream, closer, err := h.FaultTolerantClient() 553 if err != nil { 554 return nil, err 555 } 556 defer closer.Close() 557 return upstream.GetSystemTransactionResult(context, req) 558 } 559 560 func (h *FlowAccessAPIForwarder) GetTransactionResultByIndex(context context.Context, req *access.GetTransactionByIndexRequest) (*access.TransactionResultResponse, error) { 561 // This is a passthrough request 562 upstream, closer, err := h.FaultTolerantClient() 563 if err != nil { 564 return nil, err 565 } 566 defer closer.Close() 567 return upstream.GetTransactionResultByIndex(context, req) 568 } 569 570 func (h *FlowAccessAPIForwarder) GetTransactionResultsByBlockID(context context.Context, req *access.GetTransactionsByBlockIDRequest) (*access.TransactionResultsResponse, error) { 571 // This is a passthrough request 572 upstream, closer, err := h.FaultTolerantClient() 573 if err != nil { 574 return nil, err 575 } 576 defer closer.Close() 577 return upstream.GetTransactionResultsByBlockID(context, req) 578 } 579 580 func (h *FlowAccessAPIForwarder) GetTransactionsByBlockID(context context.Context, req *access.GetTransactionsByBlockIDRequest) (*access.TransactionsResponse, error) { 581 upstream, closer, err := h.FaultTolerantClient() 582 if err != nil { 583 return nil, err 584 } 585 defer closer.Close() 586 return upstream.GetTransactionsByBlockID(context, req) 587 } 588 589 func (h *FlowAccessAPIForwarder) GetAccount(context context.Context, req *access.GetAccountRequest) (*access.GetAccountResponse, error) { 590 // This is a passthrough request 591 upstream, closer, err := h.FaultTolerantClient() 592 if err != nil { 593 return nil, err 594 } 595 defer closer.Close() 596 return upstream.GetAccount(context, req) 597 } 598 599 func (h *FlowAccessAPIForwarder) GetAccountAtLatestBlock(context context.Context, req *access.GetAccountAtLatestBlockRequest) (*access.AccountResponse, error) { 600 // This is a passthrough request 601 upstream, closer, err := h.FaultTolerantClient() 602 if err != nil { 603 return nil, err 604 } 605 defer closer.Close() 606 return upstream.GetAccountAtLatestBlock(context, req) 607 } 608 609 func (h *FlowAccessAPIForwarder) GetAccountAtBlockHeight(context context.Context, req *access.GetAccountAtBlockHeightRequest) (*access.AccountResponse, error) { 610 // This is a passthrough request 611 upstream, closer, err := h.FaultTolerantClient() 612 if err != nil { 613 return nil, err 614 } 615 defer closer.Close() 616 return upstream.GetAccountAtBlockHeight(context, req) 617 } 618 619 func (h *FlowAccessAPIForwarder) ExecuteScriptAtLatestBlock(context context.Context, req *access.ExecuteScriptAtLatestBlockRequest) (*access.ExecuteScriptResponse, error) { 620 // This is a passthrough request 621 upstream, closer, err := h.FaultTolerantClient() 622 if err != nil { 623 return nil, err 624 } 625 defer closer.Close() 626 return upstream.ExecuteScriptAtLatestBlock(context, req) 627 } 628 629 func (h *FlowAccessAPIForwarder) ExecuteScriptAtBlockID(context context.Context, req *access.ExecuteScriptAtBlockIDRequest) (*access.ExecuteScriptResponse, error) { 630 // This is a passthrough request 631 upstream, closer, err := h.FaultTolerantClient() 632 if err != nil { 633 return nil, err 634 } 635 defer closer.Close() 636 return upstream.ExecuteScriptAtBlockID(context, req) 637 } 638 639 func (h *FlowAccessAPIForwarder) ExecuteScriptAtBlockHeight(context context.Context, req *access.ExecuteScriptAtBlockHeightRequest) (*access.ExecuteScriptResponse, error) { 640 // This is a passthrough request 641 upstream, closer, err := h.FaultTolerantClient() 642 if err != nil { 643 return nil, err 644 } 645 defer closer.Close() 646 return upstream.ExecuteScriptAtBlockHeight(context, req) 647 } 648 649 func (h *FlowAccessAPIForwarder) GetEventsForHeightRange(context context.Context, req *access.GetEventsForHeightRangeRequest) (*access.EventsResponse, error) { 650 // This is a passthrough request 651 upstream, closer, err := h.FaultTolerantClient() 652 if err != nil { 653 return nil, err 654 } 655 defer closer.Close() 656 return upstream.GetEventsForHeightRange(context, req) 657 } 658 659 func (h *FlowAccessAPIForwarder) GetEventsForBlockIDs(context context.Context, req *access.GetEventsForBlockIDsRequest) (*access.EventsResponse, error) { 660 // This is a passthrough request 661 upstream, closer, err := h.FaultTolerantClient() 662 if err != nil { 663 return nil, err 664 } 665 defer closer.Close() 666 return upstream.GetEventsForBlockIDs(context, req) 667 } 668 669 func (h *FlowAccessAPIForwarder) GetNetworkParameters(context context.Context, req *access.GetNetworkParametersRequest) (*access.GetNetworkParametersResponse, error) { 670 // This is a passthrough request 671 upstream, closer, err := h.FaultTolerantClient() 672 if err != nil { 673 return nil, err 674 } 675 defer closer.Close() 676 return upstream.GetNetworkParameters(context, req) 677 } 678 679 func (h *FlowAccessAPIForwarder) GetLatestProtocolStateSnapshot(context context.Context, req *access.GetLatestProtocolStateSnapshotRequest) (*access.ProtocolStateSnapshotResponse, error) { 680 // This is a passthrough request 681 upstream, closer, err := h.FaultTolerantClient() 682 if err != nil { 683 return nil, err 684 } 685 defer closer.Close() 686 return upstream.GetLatestProtocolStateSnapshot(context, req) 687 } 688 689 func (h *FlowAccessAPIForwarder) GetExecutionResultForBlockID(context context.Context, req *access.GetExecutionResultForBlockIDRequest) (*access.ExecutionResultForBlockIDResponse, error) { 690 // This is a passthrough request 691 upstream, closer, err := h.FaultTolerantClient() 692 if err != nil { 693 return nil, err 694 } 695 defer closer.Close() 696 return upstream.GetExecutionResultForBlockID(context, req) 697 } 698 699 func (h *FlowAccessAPIForwarder) GetExecutionResultByID(context context.Context, req *access.GetExecutionResultByIDRequest) (*access.ExecutionResultByIDResponse, error) { 700 // This is a passthrough request 701 upstream, closer, err := h.FaultTolerantClient() 702 if err != nil { 703 return nil, err 704 } 705 defer closer.Close() 706 return upstream.GetExecutionResultByID(context, req) 707 }