|
|
@ -1,6 +1,7 @@ |
|
|
|
package hmyapi |
|
|
|
package hmyapi |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"encoding/hex" |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
@ -46,14 +47,16 @@ type RPCCXReceipt struct { |
|
|
|
|
|
|
|
|
|
|
|
// HeaderInformation represents the latest consensus information
|
|
|
|
// HeaderInformation represents the latest consensus information
|
|
|
|
type HeaderInformation struct { |
|
|
|
type HeaderInformation struct { |
|
|
|
BlockHash common.Hash `json:"blockHash"` |
|
|
|
BlockHash common.Hash `json:"blockHash"` |
|
|
|
BlockNumber uint64 `json:"blockNumber"` |
|
|
|
BlockNumber uint64 `json:"blockNumber"` |
|
|
|
ShardID uint32 `json:"shardID"` |
|
|
|
ShardID uint32 `json:"shardID"` |
|
|
|
Leader string `json:"leader"` |
|
|
|
Leader string `json:"leader"` |
|
|
|
ViewID uint64 `json:"viewID"` |
|
|
|
ViewID uint64 `json:"viewID"` |
|
|
|
Epoch uint64 `json:"epoch"` |
|
|
|
Epoch uint64 `json:"epoch"` |
|
|
|
Timestamp string `json:"timestamp"` |
|
|
|
Timestamp string `json:"timestamp"` |
|
|
|
UnixTime uint64 `json:"unixtime"` |
|
|
|
UnixTime uint64 `json:"unixtime"` |
|
|
|
|
|
|
|
LastCommitSig string `json:"lastCommitSig"` |
|
|
|
|
|
|
|
LastCommitBitmap string `json:"lastCommitBitmap"` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func newHeaderInformation(header *block.Header) *HeaderInformation { |
|
|
|
func newHeaderInformation(header *block.Header) *HeaderInformation { |
|
|
@ -61,15 +64,18 @@ func newHeaderInformation(header *block.Header) *HeaderInformation { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
result := &HeaderInformation{ |
|
|
|
result := &HeaderInformation{ |
|
|
|
BlockHash: header.Hash(), |
|
|
|
BlockHash: header.Hash(), |
|
|
|
BlockNumber: header.Number().Uint64(), |
|
|
|
BlockNumber: header.Number().Uint64(), |
|
|
|
ShardID: header.ShardID(), |
|
|
|
ShardID: header.ShardID(), |
|
|
|
Leader: common2.MustAddressToBech32(header.Coinbase()), |
|
|
|
Leader: common2.MustAddressToBech32(header.Coinbase()), |
|
|
|
ViewID: header.ViewID().Uint64(), |
|
|
|
ViewID: header.ViewID().Uint64(), |
|
|
|
Epoch: header.Epoch().Uint64(), |
|
|
|
Epoch: header.Epoch().Uint64(), |
|
|
|
UnixTime: header.Time().Uint64(), |
|
|
|
UnixTime: header.Time().Uint64(), |
|
|
|
Timestamp: time.Unix(header.Time().Int64(), 0).UTC().String(), |
|
|
|
Timestamp: time.Unix(header.Time().Int64(), 0).UTC().String(), |
|
|
|
|
|
|
|
LastCommitBitmap: hex.EncodeToString(header.LastCommitBitmap()), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
sig := header.LastCommitSignature() |
|
|
|
|
|
|
|
result.LastCommitSig = hex.EncodeToString(sig[:]) |
|
|
|
return result |
|
|
|
return result |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|