Skip to content

Commit 8df2fe6

Browse files
committed
fixed eblock timestamp return in wsapi
1 parent 216eaf9 commit 8df2fe6

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

common/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737

3838
//Server public key for milestone 1
3939
SERVER_PUB_KEY = "8cee85c62a9e48039d4ac294da97943c2001be1539809ea5f54721f0c5477a0a"
40-
GENESIS_DIR_BLOCK_HASH = "8f0311149ca366b48660f1663b6605dad4c6f88d129a89a4e309d7b5ddc61973"
40+
GENESIS_DIR_BLOCK_HASH = "f5252b2208a1b669130f3403903336122bb9f6de1954ceeee195c36e99db43dd"
4141
)
4242

4343
//---------------------------------------------------------------

wsapi/wsapi.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ var _ = fmt.Println
3737

3838
var server = web.NewServer()
3939

40-
var inMessageQ chan wire.FtmInternalMsg
40+
var (
41+
inMessageQ chan wire.FtmInternalMsg
42+
dbase database.Db
43+
)
4144

4245
func Start(db database.Db, inMsgQ chan wire.FtmInternalMsg) {
4346
factomapi.SetDB(db)
47+
dbase = db
4448
factomapi.SetInMsgQueue(inMsgQ)
4549
inMessageQ = inMsgQ
4650

@@ -241,7 +245,7 @@ func handleDirectoryBlock(ctx *web.Context, keymr string) {
241245
Header struct {
242246
PrevBlockKeyMR string
243247
SequenceNumber uint32
244-
TimeStamp uint64
248+
TimeStamp uint32
245249
}
246250
EntryBlockList []eblockaddr
247251
}
@@ -255,7 +259,7 @@ func handleDirectoryBlock(ctx *web.Context, keymr string) {
255259
} else {
256260
d.Header.PrevBlockKeyMR = block.Header.PrevKeyMR.String()
257261
d.Header.SequenceNumber = block.Header.DBHeight
258-
d.Header.TimeStamp = uint64(block.Header.Timestamp) * 60 //Converting from minutes to seconds
262+
d.Header.TimeStamp = block.Header.Timestamp * 60
259263
for _, v := range block.DBEntries {
260264
l := new(eblockaddr)
261265
l.ChainID = v.ChainID.String()
@@ -286,7 +290,7 @@ func handleEntryBlock(ctx *web.Context, keymr string) {
286290
BlockSequenceNumber uint32
287291
ChainID string
288292
PrevKeyMR string
289-
TimeStamp uint64
293+
TimeStamp uint32
290294
}
291295
EntryList []entryaddr
292296
}
@@ -301,7 +305,11 @@ func handleEntryBlock(ctx *web.Context, keymr string) {
301305
e.Header.BlockSequenceNumber = block.Header.EBSequence
302306
e.Header.ChainID = block.Header.ChainID.String()
303307
e.Header.PrevKeyMR = block.Header.PrevKeyMR.String()
304-
// e.Header.TimeStamp = block.Header.StartTime
308+
309+
if dblock, err := dbase.FetchDBlockByHeight(block.Header.DBHeight); err == nil {
310+
e.Header.TimeStamp = dblock.Header.Timestamp * 60
311+
}
312+
305313
for _, v := range block.Body.EBEntries {
306314
l := new(entryaddr)
307315
l.EntryHash = v.String()
@@ -317,8 +325,6 @@ func handleEntryBlock(ctx *web.Context, keymr string) {
317325
} else {
318326
ctx.Write(p)
319327
}
320-
321-
// ctx.WriteHeader(httpOK)
322328
}
323329

324330
func handleEntry(ctx *web.Context, hash string) {
@@ -350,7 +356,6 @@ func handleEntry(ctx *web.Context, hash string) {
350356
} else {
351357
ctx.Write(p)
352358
}
353-
354359
}
355360

356361
func handleChainHead(ctx *web.Context, chainid string) {

0 commit comments

Comments
 (0)