|
| 1 | +/** |
| 2 | + * Copyright Soramitsu Co., Ltd. All Rights Reserved. |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +#ifndef CPP_FILECOIN_CORE_PRIMITIVES_CHAIN_CHAIN_TIPS_MANAGER_HPP |
| 7 | +#define CPP_FILECOIN_CORE_PRIMITIVES_CHAIN_CHAIN_TIPS_MANAGER_HPP |
| 8 | + |
| 9 | +#include "primitives/tipset/tipset.hpp" |
| 10 | + |
| 11 | +namespace fc::primitives::chain { |
| 12 | + |
| 13 | + class ChainTipsManager { |
| 14 | + virtual ~ChainTipsManager() = default; |
| 15 | + // Returns the ticket that is at round 'r' in the chain behind 'head' |
| 16 | + virtual outcome::result<std::reference_wrapper<const ticket::Ticket>> |
| 17 | + getTicketFromRound(const tipset::Tipset &tipset, uint64_t rount) const = 0; |
| 18 | + |
| 19 | + // Returns the tipset that contains round r (Note: multiple rounds' worth of |
| 20 | + // tickets may exist within a single block due to losing tickets being added |
| 21 | + // to the eventually successfully generated block) |
| 22 | + virtual outcome::result<std::reference_wrapper<const tipset::Tipset>> |
| 23 | + getTipsetFromRound(const tipset::Tipset &tipset, uint64_t round) const = 0; |
| 24 | + |
| 25 | + // GetBestTipset returns the best known tipset. If the 'best' tipset hasn't |
| 26 | + // changed, then this will return the previous best tipset. |
| 27 | + virtual outcome::result<std::reference_wrapper<const tipset::Tipset>> |
| 28 | + getBestTipset() const = 0; |
| 29 | + |
| 30 | + // Adds the losing ticket to the chaintips manager so that blocks can be |
| 31 | + // mined on top of it |
| 32 | + virtual outcome::result<void> addLosingTicket( |
| 33 | + const tipset::Tipset &parent, const ticket::Ticket &ticket) = 0; |
| 34 | + |
| 35 | + }; |
| 36 | +} // namespace fc::primitives::chain |
| 37 | + |
| 38 | +#endif // CPP_FILECOIN_CORE_PRIMITIVES_CHAIN_CHAIN_TIPS_MANAGER_HPP |
0 commit comments