Skip to content

Commit

Permalink
defaultBlockTime should be time.Duration instead of int
Browse files Browse the repository at this point in the history
Signed-off-by: p4u <[email protected]>
  • Loading branch information
p4u committed Nov 9, 2023
1 parent 524ea38 commit ad28c2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions types/consts.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package types

import "time"

func Bool(b bool) *bool { return &b }

// These exported variables should be treated as constants, to be used in API
Expand Down Expand Up @@ -33,8 +35,8 @@ const (
// ArchiveURL is the default URL where the archive is retrieved from.
ArchiveURL = "/ipns/k2k4r8mdn544n7f8nprwqeo27jr1v1unsu74th57s1j8mumjck7y7cbz"

// DefaultBlockTimeSeconds is the default block time in seconds.
DefaultBlockTimeSeconds = 12
// DefaultBlockTime is the default block time in seconds.
DefaultBlockTime = 12 * time.Second

// KeyKeeperMaxKeyIndex is the maxim number of allowed encryption keys.
KeyKeeperMaxKeyIndex = 16
Expand Down
4 changes: 2 additions & 2 deletions vochain/indexer/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ func (idx *Indexer) ImportArchive(archive []*ArchiveProcess) ([]*ArchiveProcess,
startDate = *p.StartDate
} else {
// Calculate startDate equal to time.Now() minus defaultBlockTime*p.ProcessInfo.BlockCount
startDate = time.Now().Add(-types.DefaultBlockTimeSeconds * time.Duration(p.ProcessInfo.BlockCount))
startDate = time.Now().Add(-types.DefaultBlockTime * time.Duration(p.ProcessInfo.BlockCount))
}
}
endDate := p.ProcessInfo.EndDate
if endDate.IsZero() {
// Calculate endDate equal to startDate plus defaultBlockTime*p.ProcessInfo.BlockCount
endDate = startDate.Add(types.DefaultBlockTimeSeconds * time.Duration(p.ProcessInfo.BlockCount))
endDate = startDate.Add(types.DefaultBlockTime * time.Duration(p.ProcessInfo.BlockCount))
}

// Create and store process in the indexer database
Expand Down
2 changes: 1 addition & 1 deletion vochain/vochaininfo/vochaininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (vi *VochainInfo) Height() uint64 {
// Value 0 means there is not yet an average.
func (vi *VochainInfo) BlockTimes() *[5]uint64 {
if vi.vnode.IsSynchronizing() {
return &[5]uint64{types.DefaultBlockTimeSeconds, 0, 0, 0, 0}
return &[5]uint64{uint64(types.DefaultBlockTime.Seconds()), 0, 0, 0, 0}
}
vi.lock.RLock()
defer vi.lock.RUnlock()
Expand Down

0 comments on commit ad28c2f

Please sign in to comment.