Route program_id to program entrypoint

This commit is contained in:
Michael Vines
2018-11-17 17:02:14 -08:00
committed by Grimes
parent ff386d6585
commit 3822c29415
11 changed files with 77 additions and 35 deletions

View File

@@ -194,6 +194,7 @@ SOL_FN_PREFIX void _sol_panic(uint64_t line) {
*/
typedef struct {
uint64_t tick_height; /** Current ledger tick */
const SolPubkey *program_id; /** program_id of the currently executing program */
} SolClusterInfo;
/**
@@ -269,6 +270,9 @@ SOL_FN_PREFIX bool sol_deserialize(
if (cluster_info != NULL) {
cluster_info->tick_height = *(uint64_t *) input;
input += sizeof(uint64_t);
cluster_info->program_id = (SolPubkey *) input;
input += sizeof(SolPubkey);
}
return true;
}

View File

@@ -15,11 +15,16 @@ extern bool entrypoint(const uint8_t *input) {
if (!sol_deserialize(input, ka, SOL_ARRAY_SIZE(ka), &ka_len, &data, &data_len, &info)) {
return false;
}
sol_log("Tick height:");
sol_log_64(info.tick_height, 0, 0, 0, 0);
sol_log("Program identifier:");
sol_log_key(info.program_id);
// Log the provided account keys and instruction input data. In the case of
// the no-op program, no account keys or input data are expected but real
// programs will have specific requirements so they can do their work.
sol_log("Account keys and instruction input data:");
sol_log_params(ka, ka_len, data, data_len);
return true;
}

View File

@@ -16,11 +16,15 @@ extern bool entrypoint(const uint8_t *input) {
if (!sol_deserialize(input, ka, SOL_ARRAY_SIZE(ka), &ka_len, &data, &data_len, &info)) {
return false;
}
sol_log("Tick height:");
sol_log_64(info.tick_height, 0, 0, 0, 0);
sol_log("Program identifier:");
sol_log_key(info.program_id);
// Log the provided account keys and instruction input data. In the case of
// the no-op program, no account keys or input data are expected but real
// programs will have specific requirements so they can do their work.
sol_log("Account keys and instruction input data:");
sol_log_params(ka, ka_len, data, data_len);
return true;
}