|
1 | 1 | package org.tron.application; |
2 | 2 |
|
| 3 | +import static org.tron.core.Constant.BLOCK_DB_NAME; |
| 4 | +import static org.tron.core.Constant.TRANSACTION_DB_NAME; |
| 5 | + |
3 | 6 | import com.google.inject.AbstractModule; |
4 | 7 | import com.google.inject.Provides; |
5 | 8 | import com.google.inject.Singleton; |
| 9 | +import javax.inject.Named; |
6 | 10 | import org.tron.consensus.client.Client; |
7 | 11 | import org.tron.consensus.server.Server; |
| 12 | +import org.tron.core.Blockchain; |
8 | 13 | import org.tron.core.Constant; |
9 | 14 | import org.tron.storage.leveldb.LevelDbDataSourceImpl; |
10 | 15 |
|
11 | | -import javax.inject.Named; |
12 | | - |
13 | | -import static org.tron.core.Constant.BLOCK_DB_NAME; |
14 | | -import static org.tron.core.Constant.TRANSACTION_DB_NAME; |
15 | | - |
16 | 16 | public class Module extends AbstractModule { |
17 | 17 |
|
18 | | - @Override |
19 | | - protected void configure() { |
20 | | - |
21 | | - } |
22 | | - |
23 | | - @Provides |
24 | | - @Singleton |
25 | | - public Client buildClient() { |
26 | | - return new Client(); |
27 | | - } |
28 | | - |
29 | | - @Provides |
30 | | - @Singleton |
31 | | - public Server buildServer() { |
32 | | - return new Server(); |
33 | | - } |
34 | | - |
35 | | - @Provides |
36 | | - @Singleton |
37 | | - @Named("transaction") |
38 | | - public LevelDbDataSourceImpl buildTransactionDb() { |
39 | | - LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL,TRANSACTION_DB_NAME); |
40 | | - db.initDB(); |
41 | | - return db; |
42 | | - } |
43 | | - |
44 | | - @Provides |
45 | | - @Singleton |
46 | | - @Named("block") |
47 | | - public LevelDbDataSourceImpl buildBlockDb() { |
48 | | - LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL,BLOCK_DB_NAME); |
49 | | - db.initDB(); |
50 | | - return db; |
51 | | - } |
| 18 | + @Override |
| 19 | + protected void configure() { |
| 20 | + |
| 21 | + } |
| 22 | + |
| 23 | + @Provides |
| 24 | + @Singleton |
| 25 | + public Client buildClient() { |
| 26 | + return new Client(); |
| 27 | + } |
| 28 | + |
| 29 | + @Provides |
| 30 | + @Singleton |
| 31 | + public Server buildServer() { |
| 32 | + return new Server(); |
| 33 | + } |
| 34 | + |
| 35 | + @Provides |
| 36 | + @Singleton |
| 37 | + @Named("transaction") |
| 38 | + public LevelDbDataSourceImpl buildTransactionDb() { |
| 39 | + LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL, TRANSACTION_DB_NAME); |
| 40 | + db.initDB(); |
| 41 | + return db; |
| 42 | + } |
| 43 | + |
| 44 | + @Provides |
| 45 | + @Singleton |
| 46 | + @Named("block") |
| 47 | + public LevelDbDataSourceImpl buildBlockDb() { |
| 48 | + LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Constant.NORMAL, BLOCK_DB_NAME); |
| 49 | + db.initDB(); |
| 50 | + return db; |
| 51 | + } |
| 52 | + |
| 53 | + @Provides |
| 54 | + @Singleton |
| 55 | + public Blockchain buildBlockchain(@Named("block") LevelDbDataSourceImpl blockDB) { |
| 56 | + return new Blockchain(blockDB); |
| 57 | + } |
52 | 58 | } |
0 commit comments