Conversation
macols77
left a comment
There was a problem hiding this comment.
Thanks for this feature! Impressive work and it's a very clean way of implementing it but could you take a look at the comments I left whenever you have some time?
Thanks a lot!
| .with_label_values(&["index_block"]) | ||
| .start_timer(); | ||
|
|
||
| self.alkanes_indexer.lock().unwrap().index_block(&bitcoin_block, height); |
There was a problem hiding this comment.
Can you return UpdaterError::Mutex error instead of unwrap?
| } | ||
|
|
||
| pub fn index_block(&mut self, block: &BitcoinBlock, height: u64) { | ||
| let mut context = self.runtime.context.lock().unwrap(); |
| }), | ||
| }; | ||
| let mut payload = Vec::new(); | ||
| request.encode(&mut payload).unwrap(); |
| use std::any::Any; | ||
|
|
||
| pub trait Store: std::fmt::Debug + Any { | ||
| fn as_any(&self) -> &dyn Any; |
| impl Updater { | ||
| pub fn new( | ||
| db: Arc<dyn Store + Send + Sync>, | ||
| db: Arc<crate::db::RocksDB>, |
| shutdown_flag: Arc<AtomicBool>, | ||
| sender: Option<Sender<Event>>, | ||
| ) -> Self { | ||
| let alkanes_indexer = Mutex::new(AlkanesIndexer::new(db.clone())); |
There was a problem hiding this comment.
It's better to pass the alkanes_indexer as parameter rather than changing the db type.
| )); | ||
| index.validate_index()?; | ||
|
|
||
| let alkanes_indexer = Arc::new(alkanes::indexer::AlkanesIndexer::new(db_arc.clone())); |
There was a problem hiding this comment.
Alkanes should be optional. Use the options.rs
| Ok(()) | ||
| } | ||
|
|
||
| pub fn put_cf<K: AsRef<[u8]>, V: AsRef<[u8]>>( |
There was a problem hiding this comment.
why do you need this set of methods in the rocksdb if you've created a add_misc_batch in the block cache?
chore: address error handling, database access, configuration, and some cleanup
|
Merged subfrost/Titan#1 |
|
|
||
|
|
||
| #[derive(Deserialize)] | ||
|
|
There was a problem hiding this comment.
Can you fix lint here please? run cargo fmt
|
|
||
| pub struct Index { | ||
| db: Arc<dyn Store + Send + Sync>, | ||
| db: Arc<RocksDB>, |
There was a problem hiding this comment.
Why are you removing the Store interface?
There was a problem hiding this comment.
It requires a downcast to construct the AlkanesIndexer I wrote so I can either have the downcast or I can update AlkanesIndexer to use the StoreWithLock type.
There was a problem hiding this comment.
The traits in MetashrewRuntime for KeyValueStoreLike relies on RocksDB specific methods, particularly iterator_cf, which doesn't really get used by alkanes.wasm anyway.
Either way, it is simplest just to downcast, so I will reintroduce that.
| for (i, tx) in bitcoin_block.txdata.iter().enumerate() { | ||
| let txid = tx.compute_txid().into(); | ||
| match transaction_parser.parse(cache, u32::try_from(i).unwrap(), tx) { | ||
| match transaction_parser.parse(cache, u32::try_from(i).map_err(|_| UpdaterError::Mutex)?, tx) { |
There was a problem hiding this comment.
This unwrap is not a mutex. It's safe to unwrap since it's a u32 and there is no way a bitcoin block can have more than u32::MAX.
I'd rather do:
match transaction_parser.parse(cache, u32::try_from(i).expect("transaction index exceeds u32::MAX"), tx)
chore: reintroduce downcast
…es genesis block at 880000
Imports metashrew-runtime v9.0.1 for latest stable wasmtime environment to run ./vendor/alkanes.wasm built from latest tagged release (v2.1.4)
Includes in BlockCache updater k/v flush from alkanes per block, into ALKANES_CF.
Extends REST API of Titan and translates between REST/JSON to protobuf types for indexer view APIs.