Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store the list of affected addresses for each transaction in the light node mode #1389

Open
Tracked by #1052
nickeskov opened this issue Apr 22, 2024 · 0 comments
Open
Tracked by #1052

Comments

@nickeskov
Copy link
Member

nickeskov commented Apr 22, 2024

Related to this TODO:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant