Skip to content

Commit 9c4754e

Browse files
committed
Added Properties object and call
1 parent 454152e commit 9c4754e

2 files changed

Lines changed: 33 additions & 5 deletions

File tree

common/constants.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ const (
2828

2929
COMMIT_TIME_WINDOW = time.Duration(12) //Time windows for commit chain and commit entry +/- 12 hours
3030

31+
32+
// maxProtocolVersion is the max protocol version the peer supports.
3133
//Common constants
32-
VERSION_0 = byte(0)
33-
NETWORK_ID_DB = uint32(4203931041) //0xFA92E5A1
34-
NETWORK_ID_EB = uint32(4203931042) //0xFA92E5A2
35-
NETWORK_ID_CB = uint32(4203931043) //0xFA92E5A3
34+
VERSION_0 = byte(0)
35+
FACTOMD_VERSION = 3001 //version starts from 1000 for Factom
36+
NETWORK_ID_DB = uint32(4203931041) //0xFA92E5A1
37+
NETWORK_ID_EB = uint32(4203931042) //0xFA92E5A2
38+
NETWORK_ID_CB = uint32(4203931043) //0xFA92E5A3
3639

3740
//For Factom TestNet
3841
NETWORK_ID_TEST = uint32(0) //0x0
@@ -85,3 +88,11 @@ var FACTOID_CHAINID = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8588
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0f}
8689

8790
var ZERO_HASH = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
91+
92+
// Structure for reporting properties (used by the web API
93+
//
94+
type Properties struct {
95+
Protocol_Version int
96+
Factomd_Version int
97+
Fctwallet_Version int
98+
}

wsapi/wsapi.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/FactomProject/FactomCode/factomapi"
1717
"github.com/FactomProject/FactomCode/util"
1818
"github.com/FactomProject/btcd/wire"
19+
"github.com/FactomProject/btcd"
1920
fct "github.com/FactomProject/factoid"
2021
"github.com/hoisie/web"
2122
)
@@ -62,6 +63,7 @@ func Start(db database.Db, inMsgQ chan wire.FtmInternalMsg) {
6263
server.Get("/v1/entry-credit-balance/([^/]+)", handleEntryCreditBalance)
6364
server.Get("/v1/factoid-balance/([^/]+)", handleFactoidBalance)
6465
server.Get("/v1/factoid-get-fee/", handleGetFee)
66+
server.Get("/v1/properties/",handleProperties)
6567

6668
wsLog.Info("Starting server")
6769
go server.Run("localhost:" + strconv.Itoa(portNumber))
@@ -71,6 +73,22 @@ func Stop() {
7173
server.Close()
7274
}
7375

76+
func handleProperties(ctx *web.Context) {
77+
78+
r := new(common.Properties)
79+
r.Factomd_Version = common.FACTOMD_VERSION
80+
r.Protocol_Version = btcd.ProtocolVersion
81+
82+
if p, err := json.Marshal(r); err != nil {
83+
wsLog.Error(err)
84+
ctx.WriteHeader(httpBad)
85+
ctx.Write([]byte(err.Error()))
86+
return
87+
} else {
88+
ctx.Write(p)
89+
}
90+
}
91+
7492
func handleCommitChain(ctx *web.Context) {
7593
type commitchain struct {
7694
CommitChainMsg string
@@ -114,7 +132,6 @@ func handleCommitChain(ctx *web.Context) {
114132
return
115133
}
116134

117-
// ctx.WriteHeader(httpOK)
118135
}
119136

120137
func handleRevealChain(ctx *web.Context) {

0 commit comments

Comments
 (0)