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 { ...@@ -273,7 +273,7 @@ func CommentProposalCmd() *cobra.Command {
func addCommentProposalflags(cmd *cobra.Command) { func addCommentProposalflags(cmd *cobra.Command) {
cmd.Flags().StringP("proposalID", "p", "", "proposal ID") cmd.Flags().StringP("proposalID", "p", "", "proposal ID")
cmd.MarkFlagRequired("proposalID") 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.Flags().StringP("comment", "c", "", "comment")
cmd.MarkFlagRequired("comment") cmd.MarkFlagRequired("comment")
} }
...@@ -281,12 +281,12 @@ func addCommentProposalflags(cmd *cobra.Command) { ...@@ -281,12 +281,12 @@ func addCommentProposalflags(cmd *cobra.Command) {
func commentProposal(cmd *cobra.Command, args []string) { func commentProposal(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
proposalID, _ := cmd.Flags().GetString("proposalID") proposalID, _ := cmd.Flags().GetString("proposalID")
repCmtHash, _ := cmd.Flags().GetString("repCmtHash") repHash, _ := cmd.Flags().GetString("repHash")
comment, _ := cmd.Flags().GetString("comment") comment, _ := cmd.Flags().GetString("comment")
params := &auty.Comment{ params := &auty.Comment{
ProposalID: proposalID, ProposalID: proposalID,
RepCmtHash: repCmtHash, RepHash: repHash,
Comment: comment, Comment: comment,
} }
var res string var res string
......
...@@ -174,10 +174,11 @@ func saveCommentHeightIndex(res *auty.ReceiptProposalComment) (kvs []*types.KeyV ...@@ -174,10 +174,11 @@ func saveCommentHeightIndex(res *auty.ReceiptProposalComment) (kvs []*types.KeyV
kv := &types.KeyValue{} kv := &types.KeyValue{}
kv.Key = calcCommentHeight(res.Cmt.ProposalID, dapp.HeightIndexStr(res.Height, int64(res.Index))) kv.Key = calcCommentHeight(res.Cmt.ProposalID, dapp.HeightIndexStr(res.Height, int64(res.Index)))
kv.Value = types.Encode(&auty.RelationCmt{ kv.Value = types.Encode(&auty.RelationCmt{
RepCmtHash: res.Cmt.RepCmtHash, RepHash: res.Cmt.RepHash,
Comment: res.Cmt.Comment, Comment: res.Cmt.Comment,
Height: res.Height, Height: res.Height,
Index: res.Index, Index: res.Index,
Hash: res.Hash,
}) })
kvs = append(kvs, kv) kvs = append(kvs, kv)
return kvs return kvs
......
...@@ -271,7 +271,7 @@ func TestExecLocalCommentProp(t *testing.T) { ...@@ -271,7 +271,7 @@ func TestExecLocalCommentProp(t *testing.T) {
receiptCmt := &auty.ReceiptProposalComment{ receiptCmt := &auty.ReceiptProposalComment{
Cmt: &auty.Comment{ Cmt: &auty.Comment{
ProposalID: propID, ProposalID: propID,
RepCmtHash: Repcmt, RepHash: Repcmt,
Comment: comment, Comment: comment,
}, },
Height: 11, Height: 11,
...@@ -298,7 +298,7 @@ func TestExecDelLocalCommentProp(t *testing.T) { ...@@ -298,7 +298,7 @@ func TestExecDelLocalCommentProp(t *testing.T) {
receiptCmt := &auty.ReceiptProposalComment{ receiptCmt := &auty.ReceiptProposalComment{
Cmt: &auty.Comment{ Cmt: &auty.Comment{
ProposalID: propID, ProposalID: propID,
RepCmtHash: Repcmt, RepHash: Repcmt,
Comment: comment, Comment: comment,
}, },
Height: 11, Height: 11,
...@@ -348,7 +348,7 @@ func TestListProposalComment(t *testing.T) { ...@@ -348,7 +348,7 @@ func TestListProposalComment(t *testing.T) {
testcase = append(testcase, testcase1...) testcase = append(testcase, testcase1...)
testcase = append(testcase, testcase2...) testcase = append(testcase, testcase2...)
cur := &auty.RelationCmt{ cur := &auty.RelationCmt{
RepCmtHash: "aaaaaa", RepHash: "aaaaaa",
Comment: "bbbbbbbbbb", Comment: "bbbbbbbbbb",
} }
for _, tcase := range testcase { for _, tcase := range testcase {
......
...@@ -331,15 +331,15 @@ func (a *action) commentProp(cm *auty.Comment) (*types.Receipt, error) { ...@@ -331,15 +331,15 @@ func (a *action) commentProp(cm *auty.Comment) (*types.Receipt, error) {
var logs []*types.ReceiptLog var logs []*types.ReceiptLog
var kv []*types.KeyValue 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) logs = append(logs, receiptLog)
return &types.Receipt{Ty: types.ExecOk, KV: kv, Logs: logs}, nil 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 := &types.ReceiptLog{}
log.Ty = ty 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) log.Log = types.Encode(r)
return log return log
} }
......
...@@ -537,7 +537,7 @@ func TestComment(t *testing.T) { ...@@ -537,7 +537,7 @@ func TestComment(t *testing.T) {
comment := "3333333333" comment := "3333333333"
opt1 := &auty.Comment{ opt1 := &auty.Comment{
ProposalID: propID, ProposalID: propID,
RepCmtHash: Repcmt, RepHash: Repcmt,
Comment: comment, Comment: comment,
} }
pbtx, err := commentPropTx(opt1) pbtx, err := commentPropTx(opt1)
...@@ -569,7 +569,7 @@ func TestComment(t *testing.T) { ...@@ -569,7 +569,7 @@ func TestComment(t *testing.T) {
err = types.Decode(value, cmt) err = types.Decode(value, cmt)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, cmt.Comment, comment) 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) { func commentPropTx(parm *auty.Comment) (*types.Transaction, error) {
......
...@@ -81,7 +81,7 @@ message TransferFund { ...@@ -81,7 +81,7 @@ message TransferFund {
// Comment action // Comment action
message Comment { message Comment {
string proposalID = 1; string proposalID = 1;
string repCmtHash = 2; string repHash = 2;
string comment = 3; string comment = 3;
} }
...@@ -89,6 +89,7 @@ message ReceiptProposalComment { ...@@ -89,6 +89,7 @@ message ReceiptProposalComment {
Comment cmt = 1; Comment cmt = 1;
int64 height = 2; int64 height = 2;
int32 index = 3; int32 index = 3;
string hash = 4;
} }
// query // query
...@@ -100,10 +101,11 @@ message ReqQueryProposalComment { ...@@ -100,10 +101,11 @@ message ReqQueryProposalComment {
} }
message RelationCmt { message RelationCmt {
string repCmtHash = 1; string repHash = 1;
string comment = 2; string comment = 2;
int64 height = 3; int64 height = 3;
int32 index = 4; int32 index = 4;
string hash = 5;
} }
message ReplyQueryProposalComment { 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