Skip to content

Commit

Permalink
Fix circular dependency in PendingStateImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalinin committed Mar 23, 2018
1 parent f436f37 commit 4ca9837
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,9 @@ public TransactionSortedSet() {
private Block best = null;

@Autowired
public PendingStateImpl(final EthereumListener listener, final BlockchainImpl blockchain) {
public PendingStateImpl(final EthereumListener listener) {
this.listener = listener;
this.blockchain = blockchain;
// this.repository = blockchain.getRepository();
this.blockStore = blockchain.getBlockStore();
this.programInvokeFactory = blockchain.getProgramInvokeFactory();
this.transactionStore = blockchain.getTransactionStore();
}

public void init() {
Expand Down Expand Up @@ -447,7 +443,11 @@ private Block createFakePendingBlock() {
return block;
}

@Autowired
public void setBlockchain(BlockchainImpl blockchain) {
this.blockchain = blockchain;
this.blockStore = blockchain.getBlockStore();
this.programInvokeFactory = blockchain.getProgramInvokeFactory();
this.transactionStore = blockchain.getTransactionStore();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ private BlockchainImpl createBlockchain(Genesis genesis) {

blockchain.byTest = true;

pendingState = new PendingStateImpl(listener, blockchain);
pendingState = new PendingStateImpl(listener);

pendingState.setBlockchain(blockchain);
blockchain.setPendingState(pendingState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ public static BlockchainImpl createBlockchain(Genesis genesis) {

blockchain.byTest = true;

PendingStateImpl pendingState = new PendingStateImpl(listener, blockchain);
PendingStateImpl pendingState = new PendingStateImpl(listener);

pendingState.setBlockchain(blockchain);
blockchain.setPendingState(pendingState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private Blockchain createBlockchain(Genesis genesis) {

blockchain.byTest = true;

PendingStateImpl pendingState = new PendingStateImpl(new EthereumListenerAdapter(), blockchain);
PendingStateImpl pendingState = new PendingStateImpl(new EthereumListenerAdapter());

pendingState.setBlockchain(blockchain);
blockchain.setPendingState(pendingState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public List<String> runTestCase(BlockTestCase testCase) {
.withParentBlockHeaderValidator(CommonConfig.getDefault().parentHeaderValidator());
blockchain.byTest = true;

PendingStateImpl pendingState = new PendingStateImpl(new EthereumListenerAdapter(), blockchain);
PendingStateImpl pendingState = new PendingStateImpl(new EthereumListenerAdapter());

blockchain.setBestBlock(genesis);
blockchain.setTotalDifficulty(genesis.getCumulativeDifficulty());
Expand Down

0 comments on commit 4ca9837

Please sign in to comment.