|
14 | 14 | // You should have received a copy of the GNU Affero General Public License |
15 | 15 | // along with this program. If not, see <https://www.gnu.org/licenses/>. |
16 | 16 |
|
17 | | -use crate::core::{AccountManager, CheckTxHandler, TransactionExecutor}; |
| 17 | +use crate::core::{AccountManager, AccountView, CheckTxHandler, TransactionExecutor}; |
18 | 18 | use crate::error::Error; |
19 | | -use crate::internal::{add_balance, get_account, get_sequence, sub_balance}; |
| 19 | +use crate::internal::{add_balance, get_account, get_balance, get_sequence, sub_balance}; |
20 | 20 | use crate::types::{Action, SignedTransaction}; |
21 | 21 | use crate::{check, get_context}; |
22 | 22 | use ckey::Ed25519Public as Public; |
@@ -92,3 +92,20 @@ impl AccountManager for Manager { |
92 | 92 | context.set(account_id, account.to_vec()); |
93 | 93 | } |
94 | 94 | } |
| 95 | + |
| 96 | +#[allow(dead_code)] |
| 97 | +pub struct View {} |
| 98 | + |
| 99 | +impl AccountView for View { |
| 100 | + fn is_active(&self, account_id: &Public) -> bool { |
| 101 | + get_balance(account_id) != 0 || get_sequence(account_id) != 0 |
| 102 | + } |
| 103 | + |
| 104 | + fn get_balance(&self, account_id: &Public) -> u64 { |
| 105 | + get_balance(account_id) |
| 106 | + } |
| 107 | + |
| 108 | + fn get_sequence(&self, account_id: &Public) -> u64 { |
| 109 | + get_sequence(account_id) |
| 110 | + } |
| 111 | +} |
0 commit comments