Look up the delegated address of an ID, if any.
(&self, id: &ActorID)
| 137 | |
| 138 | /// Look up the delegated address of an ID, if any. |
| 139 | pub async fn lookup_addr(&self, id: &ActorID) -> anyhow::Result<Option<Address>> { |
| 140 | if let Some(addr) = self.get_addr(id) { |
| 141 | return Ok(Some(addr)); |
| 142 | } |
| 143 | |
| 144 | let res = self |
| 145 | .client |
| 146 | .actor_state(&Address::new_id(*id), FvmQueryHeight::Committed) |
| 147 | .await |
| 148 | .context("failed to lookup actor state")?; |
| 149 | |
| 150 | if let Some((_, actor_state)) = res.value { |
| 151 | if let Some(addr) = actor_state.delegated_address { |
| 152 | self.set_addr(*id, addr); |
| 153 | self.set_id(addr, *id); |
| 154 | return Ok(Some(addr)); |
| 155 | } |
| 156 | } |
| 157 | tracing::info!(id, height = res.height.value(), "actor not found"); |
| 158 | Ok(None) |
| 159 | } |
| 160 | |
| 161 | fn get_id(&self, addr: &Address) -> Option<ActorID> { |
| 162 | self.addr_to_id.get(addr) |
nothing calls this directly
no test coverage detected