Skip to content

Commit 4c18ce6

Browse files
foriequal0hyunsikjeong
authored andcommitted
Pass the sender address to the custom ActionHandler
1 parent d9835e6 commit 4c18ce6

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

state/src/action_handler/hit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
use ccrypto::blake256;
18+
use ckey::Address;
1819
use cmerkle::TrieMut;
1920
use ctypes::invoice::Invoice;
2021
use primitives::H256;
@@ -58,7 +59,7 @@ impl ActionHandler for HitHandler {
5859
}
5960

6061
/// `bytes` must be valid encoding of HitAction
61-
fn execute(&self, bytes: &[u8], state: &mut TopLevelState) -> ActionHandlerResult {
62+
fn execute(&self, bytes: &[u8], state: &mut TopLevelState, _sender: &Address) -> ActionHandlerResult {
6263
let action = HitAction::decode(&UntrustedRlp::new(bytes))?;
6364
let action_data = state.action_data(&self.address())?.unwrap_or_default();
6465
let prev_counter: u32 = rlp::decode(&*action_data);

state/src/action_handler/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod hit;
1919
use std::convert::From;
2020
use std::sync::Arc;
2121

22+
use ckey::Address;
2223
use cmerkle::{TrieError, TrieMut};
2324
use ctypes::invoice::Invoice;
2425
use rlp::DecoderError;
@@ -28,7 +29,7 @@ use crate::{StateError, StateResult, TopLevelState};
2829
pub trait ActionHandler: Send + Sync {
2930
fn handler_id(&self) -> u64;
3031
fn init(&self, state: &mut TrieMut) -> StateResult<()>;
31-
fn execute(&self, bytes: &[u8], state: &mut TopLevelState) -> ActionHandlerResult;
32+
fn execute(&self, bytes: &[u8], state: &mut TopLevelState, sender: &Address) -> ActionHandlerResult;
3233
}
3334

3435
pub fn find_handler_for_id<'a>(id: u64, handlers: &'a [Arc<ActionHandler>]) -> Option<&'a Arc<ActionHandler>> {

state/src/impls/top_level.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl TopLevelState {
426426
find_handler_for_id(*handler_id, db.custom_handlers()).expect("Unknown custom parcel applied!"),
427427
)
428428
};
429-
let invoice = handler.execute(bytes, self).expect("Custom action hander execution failed");
429+
let invoice = handler.execute(bytes, self, fee_payer).expect("Custom action hander execution failed");
430430
Ok(invoice)
431431
}
432432
}

0 commit comments

Comments
 (0)