|
func (a *txAppender) applySnapshotInLightNode( |
|
params *appendBlockParams, |
|
blockInfo *proto.BlockInfo, |
|
snapshot proto.BlockSnapshot, |
|
stateHash crypto.Digest, |
|
hasher *txSnapshotHasher, |
|
) (crypto.Digest, error) { |
|
if len(snapshot.TxSnapshots) != len(params.transactions) { // sanity check |
|
return crypto.Digest{}, errors.New("number of tx snapshots doesn't match number of transactions") |
|
} |
|
for i, txs := range snapshot.TxSnapshots { |
|
tx := params.transactions[i] |
|
txID, idErr := tx.GetID(a.settings.AddressSchemeCharacter) |
|
if idErr != nil { |
|
return crypto.Digest{}, idErr |
|
} |
|
if len(txs) == 0 { // sanity check |
|
return crypto.Digest{}, errors.Errorf("snapshot of txID %q cannot be empty", base58.Encode(txID)) |
|
} |
|
txSh, shErr := calculateTxSnapshotStateHash(hasher, txID, blockInfo.Height, stateHash, txs) |
|
if shErr != nil { |
|
return crypto.Digest{}, errors.Wrapf(shErr, "failed to calculate tx snapshot hash for txID %q at height %d", |
|
base58.Encode(txID), blockInfo.Height, |
|
) |
|
} |
|
stateHash = txSh |
|
regSnapshots := txSnapshot{regular: txs} |
|
if err := regSnapshots.Apply(a.txHandler.sa, tx, false); err != nil { |
|
return crypto.Digest{}, errors.Wrap(err, "failed to apply tx snapshot") |
|
} |
|
if fErr := a.blockDiffer.countMinerFee(tx); fErr != nil { |
|
return crypto.Digest{}, errors.Wrapf(fErr, "failed to count miner fee for tx %d", i+1) |
|
} |
|
// TODO: In future we have to store the list of affected addresses for each transaction here. |
|
} |
|
return stateHash, nil |
Related to this
TODO:gowaves/pkg/state/appender.go
Lines 621 to 656 in 74aaeb1