darwinia-network / dj

Darwinia bridge relayer tool implemented in nodejs
GNU General Public License v3.0
4 stars 5 forks source link

handling receipt event and confirm event #64

Closed hackfisher closed 3 years ago

hackfisher commented 4 years ago

Pseudocode

// dj tasks for events from Ethereum(web3.js) and Darwinia(polkadot.js)
match (event) {
    Some(ethereum_crosschain_receipt_event) => {
        if (receipt_block < relay_last_confirmed_block) {
            do sign_and_broadcast_to_darwinia(extrinsic(verify_receipt_call))        
        }
        else {
            let min_required_relay_confirm_block = receipt_block + 1;
            do sign_and_broadcast_to_darwinia(extrinsic(relay_proposal_call))
            push ethereum_crosschain_receipt_event
        }
    },
       Some(darwinia_relay_new_round) => {
        do sign_and_broadcast_to_darwinia(extrinsic(relay_proposal_call))
    },
    Some(darwinia_new_pending_block) => {
        do sign_and_broadcast_to_darwinia(extrinsic(relay_guard_call))
    },
    Some(darwinia_ethereum_relay_confirm_event) => {
        pull receipt_events from ethereum_crosschain_receipt_event

        for (receipt_event in receipt_events) {
            do sign_and_broadcast_to_darwinia(extrinsic(verify_receipt_call))
        }
    }
}
clearloop commented 4 years ago

Link #56