Skip to content

Commit

Permalink
Update staged tx:
Browse files Browse the repository at this point in the history
 - simplify interface
 - allow staging a single tx containing actions from multiple senders
 - use new auth service interface
  • Loading branch information
James-Mart committed Dec 11, 2024
1 parent 83a4271 commit a284b50
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ namespace SystemService
/// * `actions` - The actions to be staged
uint32_t propose(const std::vector<psibase::Action>& actions);

/// Removes (deletes) a staged transaction
///
/// A staged transaction can only be removed by its proposer.
///
/// * `id`: The ID of the database record containing the staged transaction
/// * `txid`: The unique txid of the staged transaction
void remove(uint32_t id, psibase::Checksum256 txid);

/// Indicates that the caller accepts the specified staged transaction
///
/// Depending on the staging rules enforced by the auth service of the sender
Expand All @@ -72,44 +80,20 @@ namespace SystemService
/// * `txid`: The unique txid of the staged transaction
void reject(uint32_t id, psibase::Checksum256 txid);

/// Removes (deletes) a staged transaction
///
/// A staged transaction can only be removed by the proposer, the staged tx
/// first sender, or the first sender's auth service.
///
/// * `id`: The ID of the database record containing the staged transaction
/// * `txid`: The unique txid of the staged transaction
void remove(uint32_t id, psibase::Checksum256 txid);

/// Notifies the staged-tx service that a staged transaction should be executed.
/// Typically this call is facilitated by the staged transaction's first sender's auth
/// service on behalf of the staged transaction's first sender.
///
/// * `id`: The ID of the database record containing the staged transaction
/// * `txid`: The unique txid of the staged transaction
void execute(uint32_t id, psibase::Checksum256 txid);

/// Gets a staged transaction by id. Typically used inline by auth services.
/// Gets a staged transaction by id.
///
/// * `id`: The ID of the database record containing the staged transaction
StagedTx get_staged_tx(uint32_t id);

/// Gets info needed for staged tx execution. Typically used inline by auth services.
///
/// * `id`: The ID of the database record containing the staged transaction
std::tuple<psibase::Action, std::vector<ServiceMethod>> get_exec_info(uint32_t id);
};

// clang-format off
PSIO_REFLECT(StagedTxService,
method(init),
method(propose, actions),
method(remove, id, txid),
method(accept, id, txid),
method(reject, id, txid),
method(remove, id, txid),
method(execute, id, txid),
method(get_staged_tx, id),
method(get_exec_info, id)
);
// clang-format on

Expand Down
Loading

0 comments on commit a284b50

Please sign in to comment.