-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
add support WriteBatch operations #5113
base: main
Are you sure you want to change the base?
Conversation
31c3dbf
to
9776b45
Compare
) | ||
}) | ||
|
||
func RunInvokeOnlyPutState(n *nwo.Network, orderer *nwo.Orderer, peer *nwo.Peer, fn string, startBatch bool, initial int) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a more expressive variable name than initial
? It is not obvious what this is...
And shouldn't startBatch
really be called useWriteBatch
to be consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. In this case it is passing a sign that the chaincode should call startBatch or not.
startWB, _ := strconv.ParseBool(args[0])
if startWB {
stub.StartWriteBatch()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna run these tests
useWriteBatch (on peer) | StartWriteBatch (on chaincode) |
---|---|
true | false |
false | true |
true | true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
switch function { | ||
case "invoke": | ||
return t.put(stub, args[1:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a single argument is passed right? e.g. args[1]
, better to use a variable with an expressive name to make it clear what exactly is being passed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
}, | ||
Entry("without write batch", "without write batch", false), | ||
Entry("with write batch", "with write batch", true), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to read at least one of the keys in a chaincode query after writing the transaction, to ensure end-to-end behavior is consistent regardless of useWriteBatch
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
sampleconfig/core.yaml
Outdated
@@ -659,6 +659,14 @@ chaincode: | |||
# Format for the chaincode container logs | |||
format: "%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}" | |||
|
|||
# AdditionalParams section for parameters that are passed to chaincode | |||
# to specify additional operation modes in which the peer operates. | |||
additionalParams: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe runtimeParams
would be a better name than additionalParams
in the config.
I realize the proto is called ChaincodeAdditionalParams, but we can give it a more expressive name in the context of the config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
52b3b8c
to
4790b27
Compare
Signed-off-by: Fedor Partanskiy <[email protected]>
4790b27
to
cc24ab3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me, while I think we should take care to add tests to make sure behaviour remain consistent as @manish-sethi mentioned is his comment hyperledger/fabric-rfcs#58 (comment)
Thanks @C0rWin |
#5086