Merge branch 'ci' into 'master'
Add CI See merge request riftenlabs/riftenlabs-indexer!1
This commit is contained in:
commit
703eb3dfba
3 changed files with 41 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
||||||
/target
|
/target
|
||||||
|
*.db
|
||||||
|
|
|
||||||
34
.gitlab-ci.yml
Normal file
34
.gitlab-ci.yml
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
variables:
|
||||||
|
CARGO_HOME: $CI_PROJECT_DIR/cargo
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- $CARGO_HOME
|
||||||
|
- target/
|
||||||
|
|
||||||
|
build-release:
|
||||||
|
image: rust:latest
|
||||||
|
script:
|
||||||
|
- cargo build --verbose --release
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- target/release/
|
||||||
|
expire_in: 30 days
|
||||||
|
|
||||||
|
test:
|
||||||
|
image: rust:latest
|
||||||
|
script:
|
||||||
|
- cargo test --verbose --release
|
||||||
|
|
||||||
|
format_check:
|
||||||
|
image: rust:latest
|
||||||
|
script:
|
||||||
|
- rustup component add rustfmt
|
||||||
|
- cargo fmt -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
image: rust:latest
|
||||||
|
script:
|
||||||
|
- rustup component add clippy
|
||||||
|
- cargo clippy -- -D warnings
|
||||||
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -3,7 +3,8 @@ use bitcoin_hashes::hex::ToHex;
|
||||||
use bitcoincash::{consensus::deserialize, Block};
|
use bitcoincash::{consensus::deserialize, Block};
|
||||||
use db::get_token_tvl;
|
use db::get_token_tvl;
|
||||||
use electrum_client::{Client, ElectrumApi, Param};
|
use electrum_client::{Client, ElectrumApi, Param};
|
||||||
use riftenlabs_defi::cauldron::{ParsedContract, parse_cauldron};
|
use rayon::prelude::*;
|
||||||
|
use riftenlabs_defi::cauldron::{parse_cauldron, ParsedContract};
|
||||||
use rocket::{
|
use rocket::{
|
||||||
get,
|
get,
|
||||||
http::Status,
|
http::Status,
|
||||||
|
|
@ -28,7 +29,6 @@ use std::{
|
||||||
thread,
|
thread,
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use rayon::prelude::*;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
chainutil::calculate_mtp,
|
chainutil::calculate_mtp,
|
||||||
|
|
@ -70,7 +70,7 @@ fn get_tip_height(client: &Client) -> anyhow::Result<i64> {
|
||||||
|
|
||||||
fn index_blocks(conn: Arc<Mutex<Connection>>, client: Arc<Mutex<Client>>) -> anyhow::Result<i64> {
|
fn index_blocks(conn: Arc<Mutex<Connection>>, client: Arc<Mutex<Client>>) -> anyhow::Result<i64> {
|
||||||
let last_indexed =
|
let last_indexed =
|
||||||
config_get(&conn.lock().unwrap(), KEY_LAST_INDEXED)?.unwrap_or(GENESIS_BLOCK-1);
|
config_get(&conn.lock().unwrap(), KEY_LAST_INDEXED)?.unwrap_or(GENESIS_BLOCK - 1);
|
||||||
|
|
||||||
let tip_height = get_tip_height(&client.lock().unwrap())?;
|
let tip_height = get_tip_height(&client.lock().unwrap())?;
|
||||||
let stop_height = tip_height - TRAIL_BEHIND_OFFSET;
|
let stop_height = tip_height - TRAIL_BEHIND_OFFSET;
|
||||||
|
|
@ -207,5 +207,7 @@ fn launch() -> _ {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rocket::build().manage(conn).mount("/", routes![tvl])
|
rocket::build()
|
||||||
|
.manage(conn)
|
||||||
|
.mount("/cauldron/", routes![tvl])
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue