Skip to content

Commit

Permalink
chore: Rename SourceEntry::{Dep, Header} to CellDep, HeaderDep
Browse files Browse the repository at this point in the history
  • Loading branch information
TheWaWaR committed Aug 10, 2019
1 parent e6b2c3f commit 937d793
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions script/src/syscalls/load_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ impl<'a> LoadCell<'a> {
Source::Transaction(SourceEntry::Output) => {
self.outputs.get(index).ok_or(INDEX_OUT_OF_BOUND)
}
Source::Transaction(SourceEntry::Dep) => {
Source::Transaction(SourceEntry::CellDep) => {
self.resolved_cell_deps.get(index).ok_or(INDEX_OUT_OF_BOUND)
}
Source::Transaction(SourceEntry::Header) => Err(INDEX_OUT_OF_BOUND),
Source::Transaction(SourceEntry::HeaderDep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Input) => self
.group_inputs
.get(index)
Expand All @@ -63,8 +63,8 @@ impl<'a> LoadCell<'a> {
.get(index)
.ok_or(INDEX_OUT_OF_BOUND)
.and_then(|actual_index| self.outputs.get(*actual_index).ok_or(INDEX_OUT_OF_BOUND)),
Source::Group(SourceEntry::Dep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Header) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::CellDep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::HeaderDep) => Err(INDEX_OUT_OF_BOUND),
}
}

Expand Down
8 changes: 4 additions & 4 deletions script/src/syscalls/load_cell_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ impl<'a, DL: DataLoader + 'a> LoadCellData<'a, DL> {
Source::Transaction(SourceEntry::Output) => {
self.outputs.get(index).ok_or(INDEX_OUT_OF_BOUND)
}
Source::Transaction(SourceEntry::Dep) => {
Source::Transaction(SourceEntry::CellDep) => {
self.resolved_cell_deps.get(index).ok_or(INDEX_OUT_OF_BOUND)
}
Source::Transaction(SourceEntry::Header) => Err(INDEX_OUT_OF_BOUND),
Source::Transaction(SourceEntry::HeaderDep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Input) => self
.group_inputs
.get(index)
Expand All @@ -66,8 +66,8 @@ impl<'a, DL: DataLoader + 'a> LoadCellData<'a, DL> {
.get(index)
.ok_or(INDEX_OUT_OF_BOUND)
.and_then(|actual_index| self.outputs.get(*actual_index).ok_or(INDEX_OUT_OF_BOUND)),
Source::Group(SourceEntry::Dep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Header) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::CellDep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::HeaderDep) => Err(INDEX_OUT_OF_BOUND),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions script/src/syscalls/load_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ impl<'a, DL: DataLoader + 'a> LoadHeader<'a, DL> {
.ok_or(INDEX_OUT_OF_BOUND)
.and_then(|cell_meta| self.load_header(cell_meta).ok_or(ITEM_MISSING)),
Source::Transaction(SourceEntry::Output) => Err(INDEX_OUT_OF_BOUND),
Source::Transaction(SourceEntry::Dep) => self
Source::Transaction(SourceEntry::CellDep) => self
.resolved_cell_deps
.get(index)
.ok_or(INDEX_OUT_OF_BOUND)
.and_then(|cell_meta| self.load_header(cell_meta).ok_or(ITEM_MISSING)),
Source::Transaction(SourceEntry::Header) => self
Source::Transaction(SourceEntry::HeaderDep) => self
.header_deps
.get(index)
.ok_or(INDEX_OUT_OF_BOUND)
Expand All @@ -82,8 +82,8 @@ impl<'a, DL: DataLoader + 'a> LoadHeader<'a, DL> {
})
.and_then(|cell_meta| self.load_header(cell_meta).ok_or(ITEM_MISSING)),
Source::Group(SourceEntry::Output) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Dep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Header) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::CellDep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::HeaderDep) => Err(INDEX_OUT_OF_BOUND),
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions script/src/syscalls/load_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ impl<'a> LoadInput<'a> {
self.inputs.get(index).ok_or(INDEX_OUT_OF_BOUND)
}
Source::Transaction(SourceEntry::Output) => Err(INDEX_OUT_OF_BOUND),
Source::Transaction(SourceEntry::Dep) => Err(INDEX_OUT_OF_BOUND),
Source::Transaction(SourceEntry::Header) => Err(INDEX_OUT_OF_BOUND),
Source::Transaction(SourceEntry::CellDep) => Err(INDEX_OUT_OF_BOUND),
Source::Transaction(SourceEntry::HeaderDep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Input) => self
.group_inputs
.get(index)
.ok_or(INDEX_OUT_OF_BOUND)
.and_then(|actual_index| self.inputs.get(*actual_index).ok_or(INDEX_OUT_OF_BOUND)),
Source::Group(SourceEntry::Output) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Dep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::Header) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::CellDep) => Err(INDEX_OUT_OF_BOUND),
Source::Group(SourceEntry::HeaderDep) => Err(INDEX_OUT_OF_BOUND),
}
}

Expand Down
26 changes: 13 additions & 13 deletions script/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ enum SourceEntry {
Input,
Output,
// Cell dep
Dep,
CellDep,
// Header dep
Header,
HeaderDep,
}

impl From<SourceEntry> for u64 {
fn from(s: SourceEntry) -> u64 {
match s {
SourceEntry::Input => 1,
SourceEntry::Output => 2,
SourceEntry::Dep => 3,
SourceEntry::Header => 4,
SourceEntry::CellDep => 3,
SourceEntry::HeaderDep => 4,
}
}
}
Expand All @@ -107,8 +107,8 @@ impl SourceEntry {
match i {
1 => Ok(SourceEntry::Input),
2 => Ok(SourceEntry::Output),
3 => Ok(SourceEntry::Dep),
4 => Ok(SourceEntry::Header),
3 => Ok(SourceEntry::CellDep),
4 => Ok(SourceEntry::HeaderDep),
_ => Err(Error::ParseError),
}
}
Expand Down Expand Up @@ -614,7 +614,7 @@ mod tests {
machine.set_register(A1, size_addr); // size_addr
machine.set_register(A2, 0); // offset
machine.set_register(A3, 0); //index
machine.set_register(A4, u64::from(Source::Transaction(SourceEntry::Dep))); //source: 3 dep
machine.set_register(A4, u64::from(Source::Transaction(SourceEntry::CellDep))); //source: 3 dep
machine.set_register(A5, CellField::DataHash as u64); //field: 2 data hash
machine.set_register(A7, LOAD_CELL_BY_FIELD_SYSCALL_NUMBER); // syscall number

Expand Down Expand Up @@ -684,7 +684,7 @@ mod tests {
machine.set_register(A1, size_addr); // size_addr
machine.set_register(A2, 0); // offset
machine.set_register(A3, 0); //index
machine.set_register(A4, u64::from(Source::Transaction(SourceEntry::Header))); //source: 4 header
machine.set_register(A4, u64::from(Source::Transaction(SourceEntry::HeaderDep))); //source: 4 header
machine.set_register(A7, LOAD_HEADER_SYSCALL_NUMBER); // syscall number

let data_hash = blake2b_256(&data);
Expand Down Expand Up @@ -1021,7 +1021,7 @@ mod tests {
machine.set_register(A2, 0); // content offset
machine.set_register(A3, data.len() as u64); // content size
machine.set_register(A4, 0); //index
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::Dep))); //source
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::CellDep))); //source
machine.set_register(A6, load_data_type as u64); // memory type
machine.set_register(A7, LOAD_CELL_DATA_SYSCALL_NUMBER); // syscall number

Expand Down Expand Up @@ -1104,7 +1104,7 @@ mod tests {
machine.set_register(A2, 0); // content offset
machine.set_register(A3, data.len() as u64); // content size
machine.set_register(A4, 0); //index
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::Dep))); //source
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::CellDep))); //source
machine.set_register(A6, load_data_type as u64); // memory type
machine.set_register(A7, LOAD_CELL_DATA_SYSCALL_NUMBER); // syscall number

Expand Down Expand Up @@ -1167,7 +1167,7 @@ mod tests {
machine.set_register(A2, 0); // content offset
machine.set_register(A3, data.len() as u64); // content size
machine.set_register(A4, 0); //index
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::Dep))); //source
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::CellDep))); //source
machine.set_register(A6, LoadDataType::Code as u64); // memory type
machine.set_register(A7, LOAD_CELL_DATA_SYSCALL_NUMBER); // syscall number
let dep_cell_data = Bytes::from(&data[..]);
Expand Down Expand Up @@ -1215,7 +1215,7 @@ mod tests {
machine.set_register(A2, 0); // content offset
machine.set_register(A3, data.len() as u64 + 3); // content size
machine.set_register(A4, 0); //index
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::Dep))); //source
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::CellDep))); //source
machine.set_register(A6, LoadDataType::Code as u64); // memory type
machine.set_register(A7, LOAD_CELL_DATA_SYSCALL_NUMBER); // syscall number

Expand Down Expand Up @@ -1267,7 +1267,7 @@ mod tests {
machine.set_register(A2, 0); // content offset
machine.set_register(A3, data.len() as u64); // content size
machine.set_register(A4, 0); //index
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::Dep))); //source
machine.set_register(A5, u64::from(Source::Transaction(SourceEntry::CellDep))); //source
machine.set_register(A6, LoadDataType::Code as u64); // memory type
machine.set_register(A7, LOAD_CELL_DATA_SYSCALL_NUMBER); // syscall number

Expand Down

0 comments on commit 937d793

Please sign in to comment.