MCPcopy Index your code
hub / github.com/numbersprotocol/nit / update

Function update

src/commitdb.ts:87–101  ·  view source on GitHub ↗
(assetCid, blockchainInfo, dbEntryAmount, dbEndpointUrl, accessToken=null)

Source from the content-addressed store, hash-verified

85
86// bubble -> calculate how many items to retrieve -> call update -> push extended commints to db -> return updated entry amount
87export 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
103export async function httpPost(url, data, accessToken=null) {
104 const formData = new FormData();

Callers

nothing calls this directly

Calls 2

extendCommitsFunction · 0.85
httpPostFunction · 0.85

Tested by

no test coverage detected