Skip to content

Commit d646bb8

Browse files
committed
Pass the account's storage db explicitly
1 parent 20beef9 commit d646bb8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/run-blockchain/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const level = require('level')
1515
const rlp = utils.rlp
1616

1717
async function main() {
18-
const state = new Trie()
1918
const blockchainDB = levelMem()
19+
const state = new Trie(blockchainDB)
2020

2121
const hardfork = testData.network.toLowerCase()
2222

@@ -39,7 +39,7 @@ async function main() {
3939
hardfork,
4040
})
4141

42-
await setupPreConditions(state, testData)
42+
await setupPreConditions(blockchainDB, state, testData)
4343

4444
await setGenesisBlock(blockchain, hardfork)
4545

@@ -60,16 +60,15 @@ function setEthashCache(blockchain: any) {
6060
}
6161
}
6262

63-
async function setupPreConditions(state: any, testData: any) {
63+
async function setupPreConditions(db: any, state: any, testData: any) {
6464
for (const address of Object.keys(testData.pre)) {
6565
const acctData = testData.pre[address]
6666
const account = new Account()
6767

6868
account.nonce = utils.toBuffer(acctData.nonce)
6969
account.balance = utils.toBuffer(acctData.balance)
7070

71-
const storageTrie = state.copy()
72-
storageTrie.root = null
71+
const storageTrie = new Trie(db)
7372

7473
for (const hexStorageKey of Object.keys(acctData.storage)) {
7574
const val = utils.toBuffer(acctData.storage[hexStorageKey])

0 commit comments

Comments
 (0)