From 089239776b0e3de76f36e5b10ec594ee8ade3b58 Mon Sep 17 00:00:00 2001 From: Mo Lin Date: Thu, 26 Nov 2020 15:39:28 +0800 Subject: [PATCH] add API pos_getEpochBlock --- VERSION | 2 +- internal/web3ext/web3ext.go | 5 +++++ params/version.go | 8 ++++---- pos/posapi/api.go | 8 ++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index f84efdbe9..eddb68330 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -2.1.8 +2.1.9-beta diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go index 10bea6266..3407bd96d 100644 --- a/internal/web3ext/web3ext.go +++ b/internal/web3ext/web3ext.go @@ -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', diff --git a/params/version.go b/params/version.go index a9ef7a9ce..62fa29b0e 100644 --- a/params/version.go +++ b/params/version.go @@ -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. diff --git a/pos/posapi/api.go b/pos/posapi/api.go index 5cade6ac7..cd973ba1a 100644 --- a/pos/posapi/api.go +++ b/pos/posapi/api.go @@ -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 }