Commit 47540288 authored by liuyuhang's avatar liuyuhang Committed by 33cn

add comment reply hash

parent 3436c30f
......@@ -273,7 +273,7 @@ func CommentProposalCmd() *cobra.Command {
func addCommentProposalflags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID")
cmd.Flags().StringP("repCmtHash", "r", "", "reply Comment hash")
cmd.Flags().StringP("repHash", "r", "", "reply Comment hash")
cmd.Flags().StringP("comment", "c", "", "comment")
cmd.MarkFlagRequired("comment")
}
......@@ -281,12 +281,12 @@ func addCommentProposalflags(cmd *cobra.Command) {
func commentProposal(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
proposalID, _ := cmd.Flags().GetString("proposalID")
repCmtHash, _ := cmd.Flags().GetString("repCmtHash")
repHash, _ := cmd.Flags().GetString("repHash")
comment, _ := cmd.Flags().GetString("comment")
params := &auty.Comment{
ProposalID: proposalID,
RepCmtHash: repCmtHash,
RepHash: repHash,
Comment: comment,
}
var res string
......
......@@ -174,10 +174,11 @@ func saveCommentHeightIndex(res *auty.ReceiptProposalComment) (kvs []*types.KeyV
kv := &types.KeyValue{}
kv.Key = calcCommentHeight(res.Cmt.ProposalID, dapp.HeightIndexStr(res.Height, int64(res.Index)))
kv.Value = types.Encode(&auty.RelationCmt{
RepCmtHash: res.Cmt.RepCmtHash,
RepHash: res.Cmt.RepHash,
Comment: res.Cmt.Comment,
Height: res.Height,
Index: res.Index,
Hash: res.Hash,
})
kvs = append(kvs, kv)
return kvs
......
......@@ -271,7 +271,7 @@ func TestExecLocalCommentProp(t *testing.T) {
receiptCmt := &auty.ReceiptProposalComment{
Cmt: &auty.Comment{
ProposalID: propID,
RepCmtHash: Repcmt,
RepHash: Repcmt,
Comment: comment,
},
Height: 11,
......@@ -298,7 +298,7 @@ func TestExecDelLocalCommentProp(t *testing.T) {
receiptCmt := &auty.ReceiptProposalComment{
Cmt: &auty.Comment{
ProposalID: propID,
RepCmtHash: Repcmt,
RepHash: Repcmt,
Comment: comment,
},
Height: 11,
......@@ -348,7 +348,7 @@ func TestListProposalComment(t *testing.T) {
testcase = append(testcase, testcase1...)
testcase = append(testcase, testcase2...)
cur := &auty.RelationCmt{
RepCmtHash: "aaaaaa",
RepHash: "aaaaaa",
Comment: "bbbbbbbbbb",
}
for _, tcase := range testcase {
......
......@@ -331,15 +331,15 @@ func (a *action) commentProp(cm *auty.Comment) (*types.Receipt, error) {
var logs []*types.ReceiptLog
var kv []*types.KeyValue
receiptLog := getCommentReceiptLog(cm, a.height, a.index, auty.TyLogCommentProp)
receiptLog := getCommentReceiptLog(cm, a.height, a.index, common.ToHex(a.txhash), auty.TyLogCommentProp)
logs = append(logs, receiptLog)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil
}
func getCommentReceiptLog(cur *auty.Comment, height int64, index int32, ty int32) *types.ReceiptLog {
func getCommentReceiptLog(cur *auty.Comment, height int64, index int32, hash string, ty int32) *types.ReceiptLog {
log := &types.ReceiptLog{}
log.Ty = ty
r := &auty.ReceiptProposalComment{Cmt: cur, Height: height, Index: index}
r := &auty.ReceiptProposalComment{Cmt: cur, Height: height, Index: index, Hash: hash}
log.Log = types.Encode(r)
return log
}
......
......@@ -537,7 +537,7 @@ func TestComment(t *testing.T) {
comment := "3333333333"
opt1 := &auty.Comment{
ProposalID: propID,
RepCmtHash: Repcmt,
RepHash: Repcmt,
Comment: comment,
}
pbtx, err := commentPropTx(opt1)
......@@ -569,7 +569,7 @@ func TestComment(t *testing.T) {
err = types.Decode(value, cmt)
require.NoError(t, err)
require.Equal(t, cmt.Comment, comment)
require.Equal(t, cmt.RepCmtHash, Repcmt)
require.Equal(t, cmt.RepHash, Repcmt)
}
func commentPropTx(parm *auty.Comment) (*types.Transaction, error) {
......
......@@ -81,7 +81,7 @@ message TransferFund {
// Comment action
message Comment {
string proposalID = 1;
string repCmtHash = 2;
string repHash = 2;
string comment = 3;
}
......@@ -89,6 +89,7 @@ message ReceiptProposalComment {
Comment cmt = 1;
int64 height = 2;
int32 index = 3;
string hash = 4;
}
// query
......@@ -100,10 +101,11 @@ message ReqQueryProposalComment {
}
message RelationCmt {
string repCmtHash = 1;
string comment = 2;
int64 height = 3;
int32 index = 4;
string repHash = 1;
string comment = 2;
int64 height = 3;
int32 index = 4;
string hash = 5;
}
message ReplyQueryProposalComment {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment