|
| 1 | +interface hypermap-cacher { |
| 2 | + // Metadata associated with a batch of Ethereum logs. |
| 3 | + record logs-metadata { |
| 4 | + chain-id: string, |
| 5 | + from-block: string, |
| 6 | + to-block: string, |
| 7 | + time-created: string, |
| 8 | + created-by: string, |
| 9 | + signature: string, |
| 10 | + } |
| 11 | + |
| 12 | + // Represents an item in the manifest, detailing a single log cache file. |
| 13 | + record manifest-item { |
| 14 | + metadata: logs-metadata, |
| 15 | + is-empty: bool, |
| 16 | + file-hash: string, |
| 17 | + file-name: string, |
| 18 | + } |
| 19 | + |
| 20 | + // The main manifest structure, listing all available log cache files. |
| 21 | + // WIT does not support direct map types, so a list of key-value tuples is used. |
| 22 | + record manifest { |
| 23 | + // The key is the filename of the log cache. |
| 24 | + items: list<tuple<string, manifest-item>>, |
| 25 | + manifest-filename: string, |
| 26 | + chain-id: string, |
| 27 | + protocol-version: string, |
| 28 | + } |
| 29 | + |
| 30 | + record get-logs-by-range-request { |
| 31 | + from-block: u64, |
| 32 | + to-block: option<u64>, // If None, signifies to the latest available/relevant cached block. |
| 33 | + } |
| 34 | + |
| 35 | + variant get-logs-by-range-ok-response { |
| 36 | + logs(tuple<u64, string>), |
| 37 | + latest(u64), |
| 38 | + } |
| 39 | + |
| 40 | + // Defines the types of requests that can be sent to the Hypermap Cacher process. |
| 41 | + variant cacher-request { |
| 42 | + get-manifest, |
| 43 | + get-log-cache-content(string), |
| 44 | + get-status, |
| 45 | + get-logs-by-range(get-logs-by-range-request), |
| 46 | + start-providing, |
| 47 | + stop-providing, |
| 48 | + set-nodes(list<string>), |
| 49 | + reset(option<list<string>>), |
| 50 | + } |
| 51 | + |
| 52 | + // Represents the operational status of the cacher. |
| 53 | + record cacher-status { |
| 54 | + last-cached-block: u64, |
| 55 | + chain-id: string, |
| 56 | + protocol-version: string, |
| 57 | + next-cache-attempt-in-seconds: option<u64>, |
| 58 | + manifest-filename: string, |
| 59 | + log-files-count: u32, |
| 60 | + our-address: string, |
| 61 | + is-providing: bool, |
| 62 | + } |
| 63 | + |
| 64 | + // Defines the types of responses the Hypermap Cacher process can send. |
| 65 | + variant cacher-response { |
| 66 | + get-manifest(option<manifest>), |
| 67 | + get-log-cache-content(result<option<string>, string>), |
| 68 | + get-status(cacher-status), |
| 69 | + get-logs-by-range(result<get-logs-by-range-ok-response, string>), |
| 70 | + start-providing(result<string, string>), |
| 71 | + stop-providing(result<string, string>), |
| 72 | + set-nodes(result<string, string>), |
| 73 | + reset(result<string, string>), |
| 74 | + rejected, |
| 75 | + is-starting, |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +world hypermap-cacher-sys-v0 { |
| 80 | + import sign; |
| 81 | + import hypermap-cacher; |
| 82 | + include process-v1; |
| 83 | +} |
0 commit comments