Wire state block creation and verificaiton into consensus

pull/69/head
Rongjian Lan 6 years ago
parent 80d98946d4
commit 3919360ef6
  1. 6
      blockchain/utxopool.go
  2. 6
      node/node_handler.go

@ -85,6 +85,12 @@ func (utxoPool *UTXOPool) VerifyTransactions(transactions []*Transaction) bool {
return true
}
// VerifyStateBlock verifies if the given state block matches the current utxo pool.
func (utxoPool *UTXOPool) VerifyStateBlock(stateBlock *Block) bool {
// TODO: implement this
return true
}
// VerifyOneTransaction verifies if a list of transactions valid.
func (utxoPool *UTXOPool) VerifyOneTransaction(tx *Transaction, spentTXOs *map[[20]byte]map[string]map[uint32]bool) (valid, crossShard bool) {
if len(tx.Proofs) != 0 {

@ -271,7 +271,11 @@ func (node *Node) BroadcastNewBlock(newBlock *blockchain.Block) {
// This is called by consensus participants to verify the block they are running consensus on
func (node *Node) VerifyNewBlock(newBlock *blockchain.Block) bool {
return node.UtxoPool.VerifyTransactions(newBlock.Transactions)
if bytes.Equal(newBlock.PrevBlockHash[:], (&[32]byte{})[:]) {
return node.UtxoPool.VerifyStateBlock(newBlock)
} else {
return node.UtxoPool.VerifyTransactions(newBlock.Transactions)
}
}
// This is called by consensus participants, after consensus is done, to:

Loading…
Cancel
Save