1- I've built a custom chain with unified accounts that uses PoA as its consensus, but there's no addition to the validator's balance on the confirmation of a transaction even though I've set in my code to send 90%
of the transaction fees to the block authors.
Here's my implementation:
pub struct DealWithFees;
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
impl OnUnbalanced<NegativeImbalance> for DealWithFees {
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item=NegativeImbalance>) {
if let Some(fees) = fees_then_tips.next() {
// for fees, 10% to treasury, 90% to author
let mut split = fees.ration(10, 90);
if let Some(tips) = fees_then_tips.next() {
// for tips, if any, 100% (though this can be anything)
tips.merge_into(&mut split.1);
}
// Treasury::on_unbalanced(split.0);
Author::on_unbalanced(split.1);
}
}
}
pub struct Author;
impl OnUnbalanced<NegativeImbalance> for Author {
fn on_nonzero_unbalanced(amount: NegativeImbalance) {
if let Some(author) = Authorship::author() {
Balances::resolve_creating(&author, amount);
}
}
}
Then I've called this DealWithFees
struct in pallet_transaction_payment
like this:
type OnChargeTransaction = CurrencyAdapter<Balances, DealWithFees>;
2- Secondly, is it possible to give custom rewards to the block authors on each block validation other than the tips and transaction fees?
Thanks.