Skip to content

Commit

Permalink
Fix data copy bug
Browse files Browse the repository at this point in the history
1.fix data copy bug

Signed-off-by: xizho10 <[email protected]>
  • Loading branch information
xizho10 authored and dreamfly281 committed Jul 24, 2017
1 parent 9090045 commit 933bbdd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/httprestful/common/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"time"
)

const AttributeMaxLen = 252

//record
func getRecordData(cmd map[string]interface{}) ([]byte, int64) {
if raw, ok := cmd["Raw"].(string); ok && raw == "1" {
Expand Down Expand Up @@ -93,13 +95,15 @@ func SendRecord(cmd map[string]interface{}) map[string]interface{} {

bytesBuf := bytes.NewBuffer(recordData)

buf := make([]byte, 252)
buf := make([]byte, AttributeMaxLen)
for {
n, err := bytesBuf.Read(buf)
if err != nil {
break
}
record := tx.NewTxAttribute(tx.Description, buf[0:n])
var data = make([]byte, n)
copy(data, buf[0:n])
record := tx.NewTxAttribute(tx.Description, data)
transferTx.Attributes = append(transferTx.Attributes, &record)
}
if err := VerifyAndSendTx(transferTx); err != nil {
Expand Down

0 comments on commit 933bbdd

Please sign in to comment.