Skip to content

Commit c6d18d8

Browse files
committed
add parser for timelock
1 parent 810d0e4 commit c6d18d8

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

Diff for: applications/util/blockchain/blockchain.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type ChainTransaction struct {
1616
*client.ChainTransaction
1717
//Data for the original protobuf input (Message part) and Detail left for parser
1818
ChaincodeModule, Nonce string
19+
TimeLock string `json:"expiredAt,omitempty"`
1920
Detail, Data interface{} `json:",omitempty"`
2021
TxHash string `json:",omitempty"`
2122
}
@@ -37,7 +38,7 @@ func SetParsers(m map[string]abchainTx.TxArgParser) { registryParsers = m }
3738

3839
func handleTransaction(tx *client.ChainTransaction) *ChainTransaction {
3940

40-
ret := &ChainTransaction{tx, "", "", nil, nil, ""}
41+
ret := &ChainTransaction{tx, "", "", "", nil, nil, ""}
4142

4243
if len(tx.TxArgs) < 2 {
4344
ret.Detail = notHyperledgerTx
@@ -51,6 +52,10 @@ func handleTransaction(tx *client.ChainTransaction) *ChainTransaction {
5152
}
5253
ret.Nonce = fmt.Sprintf("%X", parser.GetNonce())
5354
ret.ChaincodeModule = parser.GetCCname()
55+
if parser.GetFlags().IsTimeLock() {
56+
ret.TimeLock = parser.GetTxTime().String()
57+
}
58+
5459
ret.Data = tx.TxArgs[1]
5560
//we also add the hash of tx, for convinient
5661
ret.TxHash = fmt.Sprintf("%X", abchainTx.GetHashOfRawTx(tx.TxArgs[0], tx.TxArgs[1], tx.Method))

Diff for: client/chain_proxy.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55

66
"github.com/spf13/viper"
7+
"time"
78
)
89

910
type Chain struct {
@@ -32,7 +33,7 @@ type ChainBlock struct {
3233
Height int64 `json:",string"`
3334
Hash string `json:",omitempty"`
3435
PreviousHash string
35-
TimeStamp string `json:",omitempty"`
36+
TimeStamp time.Time `json:",omitempty"`
3637
Transactions []*ChainTransaction `json:"-"`
3738
TxEvents []*ChainTxEvents `json:"-"`
3839
}

Diff for: client/local/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (c *LocalChain) BuildBlock() {
176176
blk.PreviousHash = "Genesis"
177177
}
178178

179-
blk.TimeStamp = time.Now().String()
179+
blk.TimeStamp = time.Now()
180180
//update indexs
181181
for _, tx := range c.pendingTxs {
182182
tx.Height = blk.Height

Diff for: client/yafabric/chain.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (i blockchainInterpreter) GetBlock(h int64) (*client.ChainBlock, error) {
120120
outblk.Height = h
121121
outblk.Hash = fmt.Sprintf("%.32X...", blk.GetStateHash())
122122
outblk.PreviousHash = fmt.Sprintf("%.32X", blk.GetPreviousBlockHash())
123-
outblk.TimeStamp = utils.ConvertPBTimestamp(blk.GetTimestamp()).String()
123+
outblk.TimeStamp = utils.ConvertPBTimestamp(blk.GetTimestamp())
124124

125125
for _, tx := range blk.GetTransactions() {
126126
ret := i.resolveTx(tx)

0 commit comments

Comments
 (0)