|
| 1 | +interface binding-cacher { |
| 2 | + // Metadata associated with a batch of Ethereum logs. |
| 3 | + record binding-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 binding-manifest-item { |
| 14 | + metadata: binding-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 binding-manifest { |
| 23 | + // The key is the filename of the log cache. |
| 24 | + items: list<tuple<string, binding-manifest-item>>, |
| 25 | + manifest-filename: string, |
| 26 | + chain-id: string, |
| 27 | + protocol-version: string, |
| 28 | + } |
| 29 | + |
| 30 | + record binding-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 binding-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 binding-cacher-request { |
| 42 | + get-manifest, |
| 43 | + get-log-cache-content(string), |
| 44 | + get-status, |
| 45 | + get-logs-by-range(binding-get-logs-by-range-request), |
| 46 | + reset(option<list<string>>), |
| 47 | + start-providing, |
| 48 | + stop-providing, |
| 49 | + set-nodes(list<string>), |
| 50 | + } |
| 51 | + |
| 52 | + // Represents the operational status of the cacher. |
| 53 | + record binding-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 binding-cacher-response { |
| 66 | + get-manifest(option<binding-manifest>), |
| 67 | + get-log-cache-content(result<option<string>, string>), |
| 68 | + get-status(binding-cacher-status), |
| 69 | + get-logs-by-range(result<binding-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 | +interface hypermap-cacher { |
| 80 | + // Metadata associated with a batch of Ethereum logs. |
| 81 | + record logs-metadata { |
| 82 | + chain-id: string, |
| 83 | + from-block: string, |
| 84 | + to-block: string, |
| 85 | + time-created: string, |
| 86 | + created-by: string, |
| 87 | + signature: string, |
| 88 | + } |
| 89 | + |
| 90 | + // Represents an item in the manifest, detailing a single log cache file. |
| 91 | + record manifest-item { |
| 92 | + metadata: logs-metadata, |
| 93 | + is-empty: bool, |
| 94 | + file-hash: string, |
| 95 | + file-name: string, |
| 96 | + } |
| 97 | + |
| 98 | + // The main manifest structure, listing all available log cache files. |
| 99 | + // WIT does not support direct map types, so a list of key-value tuples is used. |
| 100 | + record manifest { |
| 101 | + // The key is the filename of the log cache. |
| 102 | + items: list<tuple<string, manifest-item>>, |
| 103 | + manifest-filename: string, |
| 104 | + chain-id: string, |
| 105 | + protocol-version: string, |
| 106 | + } |
| 107 | + |
| 108 | + record get-logs-by-range-request { |
| 109 | + from-block: u64, |
| 110 | + to-block: option<u64>, // If None, signifies to the latest available/relevant cached block. |
| 111 | + } |
| 112 | + |
| 113 | + variant get-logs-by-range-ok-response { |
| 114 | + logs(tuple<u64, string>), |
| 115 | + latest(u64), |
| 116 | + } |
| 117 | + |
| 118 | + // Defines the types of requests that can be sent to the Hypermap Cacher process. |
| 119 | + variant cacher-request { |
| 120 | + get-manifest, |
| 121 | + get-log-cache-content(string), |
| 122 | + get-status, |
| 123 | + get-logs-by-range(get-logs-by-range-request), |
| 124 | + reset(option<list<string>>), |
| 125 | + start-providing, |
| 126 | + stop-providing, |
| 127 | + set-nodes(list<string>), |
| 128 | + } |
| 129 | + |
| 130 | + // Represents the operational status of the cacher. |
| 131 | + record cacher-status { |
| 132 | + last-cached-block: u64, |
| 133 | + chain-id: string, |
| 134 | + protocol-version: string, |
| 135 | + next-cache-attempt-in-seconds: option<u64>, |
| 136 | + manifest-filename: string, |
| 137 | + log-files-count: u32, |
| 138 | + our-address: string, |
| 139 | + is-providing: bool, |
| 140 | + } |
| 141 | + |
| 142 | + // Defines the types of responses the Hypermap Cacher process can send. |
| 143 | + variant cacher-response { |
| 144 | + get-manifest(option<manifest>), |
| 145 | + get-log-cache-content(result<option<string>, string>), |
| 146 | + get-status(cacher-status), |
| 147 | + get-logs-by-range(result<get-logs-by-range-ok-response, string>), |
| 148 | + start-providing(result<string, string>), |
| 149 | + stop-providing(result<string, string>), |
| 150 | + set-nodes(result<string, string>), |
| 151 | + reset(result<string, string>), |
| 152 | + rejected, |
| 153 | + is-starting, |
| 154 | + } |
| 155 | +} |
| 156 | + |
| 157 | +world hypermap-cacher-sys-v1 { |
| 158 | + import sign; |
| 159 | + import binding-cacher; |
| 160 | + import hypermap-cacher; |
| 161 | + include process-v1; |
| 162 | +} |
0 commit comments