Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Modify timestamp type
Browse files Browse the repository at this point in the history
  • Loading branch information
ludete committed Mar 20, 2020
1 parent f53df52 commit c015c85
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/app_notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ type TxExtraInfo struct {
type NewHeightInfo struct {
ChainID string `json:"chain_id"`
Height int64 `json:"height"`
TimeStamp time.Time `json:"timestamp"`
TimeStamp int64 `json:"timestamp"`
LastBlockHash cmn.HexBytes `json:"last_block_hash"`
}

func (app *CetChainApp) pushNewHeightInfo(ctx sdk.Context) {
msg := NewHeightInfo{
ChainID: ctx.BlockHeader().ChainID,
Height: ctx.BlockHeight(),
TimeStamp: ctx.BlockHeader().Time,
TimeStamp: ctx.BlockHeader().Time.Unix(),
LastBlockHash: ctx.BlockHeader().LastBlockId.Hash,
}
bytes := dex.SafeJSONMarshal(msg)
Expand Down Expand Up @@ -176,7 +176,7 @@ type NotificationBeginRedelegation struct {
ValidatorSrc string `json:"src"`
ValidatorDst string `json:"dst"`
Amount string `json:"amount"`
CompletionTime string `json:"completion_time"`
CompletionTime int64 `json:"completion_time"`
}

func getNotificationBeginRedelegation(dualEvent []abci.Event) []byte {
Expand All @@ -189,7 +189,9 @@ func getNotificationBeginRedelegation(dualEvent []abci.Event) []byte {
} else if string(attr.Key) == sdk.AttributeKeyAmount {
res.Amount = string(attr.Value)
} else if string(attr.Key) == stypes.AttributeKeyCompletionTime {
res.CompletionTime = string(attr.Value)
if tmp, err := time.Parse(time.RFC3339, string(attr.Value)); err != nil {
res.CompletionTime = tmp.Unix()
}
}
}
for _, attr := range dualEvent[1].Attributes {
Expand All @@ -204,7 +206,7 @@ type NotificationBeginUnbonding struct {
Delegator string `json:"delegator"`
Validator string `json:"validator"`
Amount string `json:"amount"`
CompletionTime string `json:"completion_time"`
CompletionTime int64 `json:"completion_time"`
}

func getNotificationBeginUnbonding(dualEvent []abci.Event) []byte {
Expand All @@ -215,7 +217,9 @@ func getNotificationBeginUnbonding(dualEvent []abci.Event) []byte {
} else if string(attr.Key) == sdk.AttributeKeyAmount {
res.Amount = string(attr.Value)
} else if string(attr.Key) == stypes.AttributeKeyCompletionTime {
res.CompletionTime = string(attr.Value)
if tmp, err := time.Parse(time.RFC3339, string(attr.Value)); err != nil {
res.CompletionTime = tmp.Unix()
}
}
}
for _, attr := range dualEvent[1].Attributes {
Expand Down

0 comments on commit c015c85

Please sign in to comment.