(assetCid, blockchainInfo, dbEntryAmount, dbEndpointUrl, accessToken=null)
| 85 | |
| 86 | // bubble -> calculate how many items to retrieve -> call update -> push extended commints to db -> return updated entry amount |
| 87 | export async function update(assetCid, blockchainInfo, dbEntryAmount, dbEndpointUrl, accessToken=null) { |
| 88 | const onchainCommitAmount = (await nit.getCommitBlockNumbers(assetCid, blockchainInfo)).length; |
| 89 | const updateFromIndex = dbEntryAmount; |
| 90 | const updateToIndex = onchainCommitAmount; |
| 91 | const extendedCommits = await extendCommits(assetCid, blockchainInfo, updateFromIndex, updateToIndex); |
| 92 | |
| 93 | for (const extendedCommit of extendedCommits) { |
| 94 | const r = await httpPost(dbEndpointUrl, extendedCommit, accessToken); |
| 95 | } |
| 96 | |
| 97 | return { |
| 98 | "originalDbEntryAmount": parseInt(dbEntryAmount), |
| 99 | "updateDbEntryAmount": updateToIndex - updateFromIndex, |
| 100 | }; |
| 101 | } |
| 102 | |
| 103 | export async function httpPost(url, data, accessToken=null) { |
| 104 | const formData = new FormData(); |
nothing calls this directly
no test coverage detected