Skip to content

Commit

Permalink
utilize precomputed acl in initializeFinalityState
Browse files Browse the repository at this point in the history
  • Loading branch information
trungnotchung authored and sfroment committed Feb 19, 2025
1 parent cd0aa85 commit cbc4951
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions packages/object/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class DRPObject implements DRPObjectBase {

this._setDRPState(vertex, preComputeLca, this._getDRPState(drp));
this._setObjectACLState(vertex, preComputeLca, this._getDRPState(acl));
this._initializeFinalityState(vertex.hash);
this._initializeFinalityState(vertex.hash, acl);

this.vertices.push(vertex);
this._notify("callFn", [vertex]);
Expand Down Expand Up @@ -287,7 +287,7 @@ export class DRPObject implements DRPObjectBase {
this._setDRPState(vertex, preComputeLca, this._getDRPState(drp));
this._setObjectACLState(vertex, preComputeLca, this._getDRPState(acl));
this.hashGraph.addVertex(vertex);
this._initializeFinalityState(vertex.hash);
this._initializeFinalityState(vertex.hash, acl);
newVertices.push(vertex);
} catch (_) {
missing.push(vertex.hash);
Expand Down Expand Up @@ -340,21 +340,8 @@ export class DRPObject implements DRPObjectBase {
}

// initialize the attestation store for the given vertex hash
private _initializeFinalityState(hash: Hash) {
if (!this.acl || !this.originalObjectACL) {
throw new Error("ObjectACL is undefined");
}
const fetchedState = this.aclStates.get(hash);
if (fetchedState !== undefined) {
const state = cloneDeep(fetchedState);
const acl = cloneDeep(this.originalObjectACL);

for (const entry of state.state) {
acl[entry.key] = entry.value;
}
// signer set equals writer set
this.finalityStore.initializeState(hash, acl.query_getFinalitySigners());
}
private _initializeFinalityState(hash: Hash, acl: ACL) {
this.finalityStore.initializeState(hash, acl.query_getFinalitySigners());
}

// check if the given peer has write permission
Expand Down

0 comments on commit cbc4951

Please sign in to comment.