Skip to content

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

@nickeskov

Description

@nickeskov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions