-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: rozhkovdmitrii <[email protected]>
- Loading branch information
Showing
16 changed files
with
313 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
class NeonTxStatData: | ||
def __init__(self, neon_tx_hash: str, neon_income: int, tx_type: str, is_canceled: bool) -> None: | ||
self.neon_tx_hash = neon_tx_hash | ||
self.neon_income = neon_income | ||
self.tx_type = tx_type | ||
self.is_canceled = is_canceled | ||
self.instructions = [] | ||
|
||
def add_instruction(self, sol_tx_hash: str, sol_spent: int, steps: int, bpf: int) -> None: | ||
self.instructions.append((sol_tx_hash, sol_spent, steps, bpf)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from ..common_neon.data import NeonTxStatData | ||
|
||
|
||
class IIndexerUser(ABC): | ||
|
||
@abstractmethod | ||
def on_neon_tx_result(self, result: NeonTxStatData): | ||
"""On Neon transaction result """ | ||
|
||
@abstractmethod | ||
def on_solana_rpc_status(self, status): | ||
"""On Solana status""" | ||
|
||
@abstractmethod | ||
def on_db_status(self, status): | ||
"""On Neon database status""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from logged_groups import logged_group | ||
|
||
from ..environment import EVM_LOADER_ID, SOLANA_URL | ||
from ..statistics_exporter.prometheus_indexer_exporter import IndexerStatistics | ||
from ..common_neon.data import NeonTxStatData | ||
from .indexer import Indexer | ||
from .i_inidexer_user import IIndexerUser | ||
|
||
|
||
@logged_group("neon.Indexer") | ||
class IndexerApp(IIndexerUser): | ||
|
||
def __init__(self, solana_url: str): | ||
self.neon_statistics = IndexerStatistics() | ||
indexer = Indexer(solana_url, self) | ||
indexer.run() | ||
|
||
def on_neon_tx_result(self, tx_stat: NeonTxStatData): | ||
self.neon_statistics.on_neon_tx_result(tx_stat) | ||
|
||
|
||
def on_db_status(self, neon_db_status: bool): | ||
self.neon_statistics.stat_commit_postgres_availability(neon_db_status) | ||
|
||
def on_solana_rpc_status(self, solana_status: bool): | ||
self.neon_statistics.stat_commit_solana_rpc_health(solana_status) | ||
|
||
|
||
@logged_group("neon.Indexer") | ||
def run_indexer(solana_url, *, logger): | ||
logger.info(f"""Running indexer with params: | ||
solana_url: {solana_url}, | ||
evm_loader_id: {EVM_LOADER_ID}""") | ||
|
||
IndexerApp(solana_url) | ||
|
||
|
||
if __name__ == "__main__": | ||
solana_url = SOLANA_URL | ||
run_indexer(solana_url) |
Oops, something went wrong.