Skip to content

Commit

Permalink
add API pos_getEpochBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
lolieatcat committed Nov 26, 2020
1 parent 305819b commit 0892397
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
2.1.8
2.1.9-beta

5 changes: 5 additions & 0 deletions internal/web3ext/web3ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ web3._extend({
call: 'pos_getEpochID',
params: 0
}),
new web3._extend.Method({
name: 'getEpochBlock',
call: 'pos_getEpochBlock',
params: 1
}),
new web3._extend.Method({
name: 'getSlotID',
call: 'pos_getSlotID',
Expand Down
8 changes: 4 additions & 4 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
)

const (
VersionMajor = 2 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 8 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
VersionMajor = 2 // Major version component of the current release
VersionMinor = 1 // Minor version component of the current release
VersionPatch = 9 // Patch version component of the current release
VersionMeta = "beta" // Version metadata to append to the version string
)

// Version holds the textual version string.
Expand Down
8 changes: 8 additions & 0 deletions pos/posapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,14 @@ func (a PosApi) GetSlotID() uint64 {
return sl
}

func (a PosApi) GetEpochBlock(epochId uint64) (uint64, error) {
ep, _ := util.CalEpochSlotID(uint64(time.Now().Unix()))
if epochId <= posconfig.FirstEpochId || epochId >= ep {
return 0, fmt.Errorf("epochID error")
}
return util.GetEpochBlock(epochId), nil
}

func (a PosApi) GetSlotCount() int {
return posconfig.SlotCount
}
Expand Down

0 comments on commit 0892397

Please sign in to comment.