All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hedera.node.app.spi.workflows.QueryContext Maven / Gradle / Ivy

There is a newer version: 0.54.1
Show newest version
/*
 * Copyright (C) 2023-2024 Hedera Hashgraph, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hedera.node.app.spi.workflows;

import com.hedera.hapi.node.base.AccountID;
import com.hedera.hapi.node.transaction.Query;
import com.hedera.node.app.spi.fees.ExchangeRateInfo;
import com.hedera.node.app.spi.fees.FeeCalculator;
import com.hedera.node.app.spi.records.BlockRecordInfo;
import com.hedera.node.app.spi.records.RecordCache;
import com.swirlds.config.api.Configuration;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;

/**
 * Context of a single query. Contains all query specific information.
 */
public interface QueryContext {

    /**
     * Returns the {@link Query} that is currently being processed.
     *
     * @return the {@link Query} that is currently being processed
     */
    @NonNull
    Query query();

    /**
     * Gets the payer {@link AccountID} for this context's query; or null if the query is free.
     *
     * @return the {@link AccountID} of the payer in this context, if there is one
     */
    @Nullable
    AccountID payer();

    /**
     * Create a new store given the store's interface. This gives read-only access to the store.
     *
     * @param storeInterface The store interface to find and create a store for
     * @param             Interface class for a Store
     * @return An implementation of store interface provided, or null if the store
     * @throws IllegalArgumentException if the storeInterface class provided is unknown to the app
     * @throws NullPointerException     if {@code clazz} is {@code null}
     */
    @NonNull
     C createStore(@NonNull Class storeInterface);

    /**
     * Returns the current {@link Configuration}.
     *
     * @return the {@link Configuration}
     */
    @NonNull
    Configuration configuration();

    /** Gets the {@link RecordCache}. */
    @NonNull
    RecordCache recordCache();

    /** Gets the {@link BlockRecordInfo}. */
    @NonNull
    BlockRecordInfo blockRecordInfo();

    /**
     * Returns information on current exchange rates
     */
    @NonNull
    ExchangeRateInfo exchangeRateInfo();

    /**
     * Get a calculator for calculating fees for the current query
     *
     * @return The {@link FeeCalculator} to use.
     */
    @NonNull
    FeeCalculator feeCalculator();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy