MCPcopy Create free account
hub / github.com/chain/Core / ApplyValidBlock

Method ApplyValidBlock

protocol/block.go:141–151  ·  view source on GitHub ↗

ApplyValidBlock creates an updated snapshot without validating the block.

(block *legacy.Block)

Source from the content-addressed store, hash-verified

139// ApplyValidBlock creates an updated snapshot without validating the
140// block.
141func (c *Chain) ApplyValidBlock(block *legacy.Block) (*state.Snapshot, error) {
142 newSnapshot := state.Copy(c.state.snapshot)
143 err := newSnapshot.ApplyBlock(legacy.MapBlock(block))
144 if err != nil {
145 return nil, err
146 }
147 if block.AssetsMerkleRoot != newSnapshot.Tree.RootHash() {
148 return nil, ErrBadStateRoot
149 }
150 return newSnapshot, nil
151}
152
153// CommitBlock commits a block to the blockchain. The block
154// must already have been applied with ApplyValidBlock or

Callers 1

applyBlockFunction · 0.80

Calls 2

ApplyBlockMethod · 0.80
RootHashMethod · 0.80

Tested by

no test coverage detected