git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 6fea6a822c06422806c410ed001c872285269aa2

Kernel: add nonce check

Alex Beregszaszi committed on 8/23/2016, 12:27:46 AM
Parent: 096148fb99184a312360d7114166031362ecc54b

Files changed

index.jschanged
index.jsView
@@ -142,8 +142,14 @@
142142 if (!fromAccount) {
143143 throw new Error('Sender account not found: ' + tx.from.toString())
144144 }
145145
146+ if (fromAccount.get('nonce').gt(tx.nonce)) {
147+ throw new Error(`Invalid nonce: ${fromAccount.get('nonce')} > ${tx.nonce}`)
148+ }
149+
150+ fromAccount.set('nonce', fromAccount.get('nonce').add(new U256(1)))
151+
146152 // Special case: contract deployment
147153 if (tx.to.isZero()) {
148154 if (tx.data.length !== 0) {
149155 console.log('This is a contract deployment transaction')

Built with git-ssb-web