3.1 KiB
3.1 KiB
Blockchain Deposit Watcher
Peatio daemons are controlled by this gem: God.
note: just we use the God if want using The Peatio in local without docker, in collection service, daemons handle by docker container.
Daemon
start daemon with the god:
god -c lib/daemons/daemons.god
When the Peatio is being initialized, the God starts all daemons
stop daemon with the god:
god stop. God will still be up.
stop God and all daemons:
god terminate
restart God:
god restart
status God:
god status
please read it
Deposit Daemon
this Daemon, become a docker service by daemons.yaml that call in service.rake
so we use new version of deposit
files:
- {$Dena_path}/app/workers/daemons/deposit.rb
- {$Dena_path}/app/workers/daemons/blockchain.rb
implementation
daemon dockerize by below code and file:
- bash -c "bundle exec ruby lib/daemons/daemons.rb deposit" (called in Alvand Service up rake)
- {$Dena_path}/lib/daemons/daemons.rb
We decided to remove to AMQP base deposit daemons and create a new deposit daemon that will work on deposit states changes and will prevent immediate proceeding of erc20 deposits.
New deposit process diagram:
- Blockchain daemon process blocks and filter platform deposits and save them in our DB. document
- In the deposit daemons we select each 60s deposits with state
processingandfee_processing. - For
processingdeposits we are checking if plugin implement methodprepare_deposit_collection!if it doesn't we immediately process the deposit and collect deposit to thehot,warm,coldwallets.
this collection is done with help of WalletService class, that one of its responsibility is spreading between wallets. read more about WalletService
every deposit record has column namedspreadthat getting array value like this:
[{"to_address"=>"xyxzx", "amount"=>"0.00083", "currency_id"=>"btc", "status"=>"pending", "hash"=>"dcffd5b7fabaa"}],
valued by (spread_between_wallets!function in deposit model) that was called in this daemon
each row of the Spread array, will become transaction record and will be send to the Blockchain by WalletService and its the Adapter (collect_deposit!function).
If plugin implement methodprepare_deposit_collection!daemon processing of collection fees and change deposit state tofee_processing.
For deposits withfee_processingstate, we select each minute deposits that haveupdated_atolder than 5 minutes and process them. With time condition we are sure that fee transaction has already been executed.
graph TD
A((Blockchain)) -->|Deposit| B[Blockchain Daemon]
B --> |waiting for numbers of confirmations| C[Deposit Daemon]
D(BlockchainService) --> B
E(WalletService) --> C
