Skip to content

Make add value optional and stop writing it in consensusOrderedCollection #24264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ interface IConsensusOrderedCollectionValue<T> {
interface IConsensusOrderedCollectionAddOperation<T> {
opName: "add";
// serialized value
value: string;
value?: string;
deserializedValue?: T;
}

@@ -138,19 +138,19 @@ export class ConsensusOrderedCollection<T = any>
* Add a value to the consensus collection.
*/
public async add(value: T): Promise<void> {
const valueSer = this.serializeValue(value, this.serializer);

if (!this.isAttached()) {
// For the case where this is not attached yet, explicitly JSON
// clone the value to match the behavior of going thru the wire.
const addValue = this.deserializeValue(valueSer, this.serializer) as T;
const addValue = this.deserializeValue(
this.serializeValue(value, this.serializer),
this.serializer,
) as T;
this.addCore(addValue);
return;
}

await this.submit<IConsensusOrderedCollectionAddOperation<T>>({
opName: "add",
value: valueSer,
deserializedValue: value,
});
}
@@ -311,6 +311,7 @@ export class ConsensusOrderedCollection<T = any>
switch (op.opName) {
case "add": {
if (op.deserializedValue === undefined) {
assert(op.value !== undefined, "Invalid add op with no value");
this.addCore(this.deserializeValue(op.value, this.serializer) as T);
} else {
this.addCore(op.deserializedValue);
Loading
Oops, something went wrong.