Skip to content

Commit

Permalink
add timestamp to block
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Jun 12, 2019
1 parent c15ebdd commit da4344d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion commands/schema/filecoin_block.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
"string",
"null"
]
},
"timestamp": {
"type": "string"
}
},
"required": [
Expand All @@ -74,7 +77,8 @@
"parents",
"proof",
"stateRoot",
"ticket"
"ticket",
"timestamp"
],
"type": "object"
},
Expand Down
3 changes: 3 additions & 0 deletions types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type Block struct {
// a challenge
Proof PoStProof `json:"proof"`

// The timestamp, in seconds since the Unix epoch, at which this block was created.
Timestamp Uint64 `json:"timestamp"`

cachedCid cid.Cid

cachedBytes []byte
Expand Down
3 changes: 2 additions & 1 deletion types/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,12 @@ func TestTriangleEncoding(t *testing.T) {
ParentWeight: Uint64(1000),
Proof: NewTestPoSt(),
StateRoot: SomeCid(),
Timestamp: Uint64(1),
}
s := reflect.TypeOf(*b)
// This check is here to request that you add a non-zero value for new fields
// to the above (and update the field count below).
require.Equal(t, 12, s.NumField()) // Note: this also counts private fields
require.Equal(t, 13, s.NumField()) // Note: this also counts private fields
testRoundTrip(t, b)
})
}
Expand Down

0 comments on commit da4344d

Please sign in to comment.