| 105 | } |
| 106 | |
| 107 | pub async fn lookup_id(&self, addr: &Address) -> anyhow::Result<Option<ActorID>> { |
| 108 | if let Ok(id) = addr.id() { |
| 109 | return Ok(Some(id)); |
| 110 | } |
| 111 | |
| 112 | if let Some(id) = self.get_id(addr) { |
| 113 | return Ok(Some(id)); |
| 114 | } |
| 115 | |
| 116 | // Using committed height because pending could change. |
| 117 | let res = self |
| 118 | .client |
| 119 | .actor_state(addr, FvmQueryHeight::Committed) |
| 120 | .await |
| 121 | .context("failed to lookup actor state")?; |
| 122 | |
| 123 | if let Some((id, _)) = res.value { |
| 124 | self.set_id(*addr, id); |
| 125 | if let Payload::Delegated(_) = addr.payload() { |
| 126 | self.set_addr(id, *addr) |
| 127 | } |
| 128 | return Ok(Some(id)); |
| 129 | } |
| 130 | tracing::info!( |
| 131 | addr = addr.to_string(), |
| 132 | height = res.height.value(), |
| 133 | "actor not found" |
| 134 | ); |
| 135 | Ok(None) |
| 136 | } |
| 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>> { |