Golang client implementation of the
factomd
and
factom-walletd
APIs.
factomproject / factom Goto Github PK
View Code? Open in Web Editor NEWLibrary for writing Factom clients in go
License: MIT License
Library for writing Factom clients in go
License: MIT License
Golang client implementation of the
factomd
and
factom-walletd
APIs.
My app parses all entry credit blocks of dblocks.
Accidentally I can not parse entry credit block c96a851d95db6d58cbcfdd63a8aaf93fc180fb8c003af5508667cc44fa31457d
of dblock number 1.
factom.GetECBlock("c96a851d95db6d58cbcfdd63a8aaf93fc180fb8c003af5508667cc44fa31457d")
returns the error:
ERRO[0002] Unknown Entry Credit Block Entry type
The same EC block returned without error via curl (factomd API):
curl -X POST --data-binary '{"jsonrpc": "2.0", "id": 0, "method": "entrycredit-block", "params": {"keymr":"c96a851d95db6d58cbcfdd63a8aaf93fc180fb8c003af5508667cc44fa31457d"}}' -H 'content-type:text/plain;' https://api.factomd.net/v2
{"jsonrpc":"2.0","id":0,"result":{"ecblock":{"header":{"bodyhash":"bb3ff38bbb90032de6965587f46dcf37551ac26e15819303057c88999b2910b4","prevheaderhash":"f87cfc073df0e82cdc2ed0bb992d7ea956fd32b435b099fc35f4b0696948507a","prevfullhash":"66fb49a15b68a2a0ce2382e6aa6970c835497c6074bec9794ccf84bb331ad135","dbheight":1,"headerexpansionarea":"","objectcount":11,"bodysize":88,"chainid":"000000000000000000000000000000000000000000000000000000000000000c","ecchainid":"000000000000000000000000000000000000000000000000000000000000000c"},"body":{"entries":[{"serverindexnumber":0},{"number":2},{"number":3},{"number":4},{"number":5},{"number":6},{"number":7},{"number":8},{"ecpubkey":"17ef7a21d1a616d65e6b73f3c6a7ad5c49340a6c2592872020ec60767ff00d7d","txid":"c3d09d10693eb867e2bd0a503746df370403c9451ae91a363046f2a68529c2fd","index":0,"numec":300},{"number":9},{"number":10}]},"headerhash":"c96a851d95db6d58cbcfdd63a8aaf93fc180fb8c003af5508667cc44fa31457d","fullhash":"1eb3121d81cd8676f20c5fec2f4e0d7a892a2ab2f086506bf55735756098d9ba"},"rawdata":"000000000000000000000000000000000000000000000000000000000000000cbb3ff38bbb90032de6965587f46dcf37551ac26e15819303057c88999b2910b4f87cfc073df0e82cdc2ed0bb992d7ea956fd32b435b099fc35f4b0696948507a66fb49a15b68a2a0ce2382e6aa6970c835497c6074bec9794ccf84bb331ad1350000000100000000000000000b0000000000000058000001020103010401050106010701080417ef7a21d1a616d65e6b73f3c6a7ad5c49340a6c2592872020ec60767ff00d7dc3d09d10693eb867e2bd0a503746df370403c9451ae91a363046f2a68529c2fd00822c0109010a"}}
Previous EC block f87cfc073df0e82cdc2ed0bb992d7ea956fd32b435b099fc35f4b0696948507a
(of DBlock 0) read by factom.GetECBlock
without errors.
https://explorer.factom.com/ecblocks/f87cfc073df0e82cdc2ed0bb992d7ea956fd32b435b099fc35f4b0696948507a
Hi!
Factom it's available for run with go compiler 1.8? The installation process give me a error when i try to run factom in linux server
$ factomd
//////////////////////// Copyright 2017 Factom Foundation
//////////////////////// Use of this source code is governed by the MIT
//////////////////////// license that can be found in the LICENSE file.
Go compiler version: go1.8
Using build: 701f2cca5ed1f71771a36f8e0386f707106190fb
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
!!! !!! !!! ERROR: unsupported compiler version !!! !!! !!!
After view this error i try to install using all.sh script but i got this another error
[INFO] Replacing existing vendor dependencies
./all.sh: line 99: cd: addservermessage: No such file or directory
Compiling: addservermessage
[ERROR] Failed to find glide.yaml file in directory tree: Cannot resolve parent of /
can't load package: package github.com/FactomProject: no buildable Go source files in /home/ubuntu/go/src/github.com/FactomProject
Regards
ER
I try to run pegnet oracleMiner and meet an issue while using factom lib:
f.info, err = factom.GetCurrentMinute()
err
:
ERRO[0006] json: cannot unmarshal number 1.5608661075125e+18 into Go struct field CurrentMinuteInfo.currenttime of type int64
Debugging inside GetCurrentMinute()
function shows, that factomd request is successful, but failed to unmarshal it:
INFO[0000] {"jsonrpc":"2.0","id":3,"result":{"stalldetected":false,"minute":2,"leaderheight":197528,"currentminutestarttime":1.5608669407298e+18,"directoryblockinseconds":600,"directoryblockheight":197528,"currenttime":1.5608669649873e+18,"currentblockstarttime":1.5608668208451e+18}}
The test fails with:
--- FAIL: TestGetPendingTransactions (0.00s)
/home/paul/go/src/github.com/FactomProject/factom/transaction_pending_test.go:33: unexpected response.
got =
[{TxID:5d87f2ba00ebaee1b0aac86b97ab5a8d4ab5f07a948966856f5723b15c57a5ab DBHeight:0 Status:TransactionACK Fees:0 Inputs:[] Outputs:[{Amount:320000000 RCDHash:d06f8b5d84395afbec25d3aa3f3f2d5a6573ebd30e4d02e797d77107395c2b4a Address:FA3YsmVnBs2LwrthnFzEJYFTw2HzhYMmjnD2GtG6W2r2S2SvonCv} {Amount:576000000 RCDHash:e8e41a1c7ca7c29dc928e509cae82cae1a4711eb12fddc8bde25bf1733069efc Address:FA3jeSpDq6JSNmizDS8TWwdxKS9EiKFeRCXyZNYrfH6eqX1K9o8u} {Amount:320000000 RCDHash:6a437b1475d9455e8447f7b2a7f32044a28f5f16486d2f239eca5bdba02030c8 Address:FA2msvDAoVgzRx8BTmxFAYDLbg2VQXqhi2HzKQHmsb4mVrKjY4B6} {Amount:320000000 RCDHash:2b20273033acf00b40e88848a853a56dd0543570f4f28d30b050634d1e28bd6e Address:FA2J59Eb8xyizJLachFn8LuRXVsSNkoW2uPKrna8X4UrtyVwztgY} {Amount:320000000 RCDHash:53c597f02efd7ef3caad48182969236a70883bada570aa316bc9b20efedcc73f Address:FA2byPxs4XYmra4Z6t3UcDwGaNP62LM631QarrqvVbrbsy9XCGoX} {Amount:320000000 RCDHash:8f3064f2d1b8fac099719de1651e81c0fc3f0f29ef1a95a3b46c90e628b51ccc Address:FA3498SdD2tDAi2485czk6shCfU5Q3PC5Wsui6sNzxi1dTpwxpFj} {Amount:320000000 RCDHash:d06f8b5d84395afbec25d3aa3f3f2d5a6573ebd30e4d02e797d77107395c2b4a Address:FA3YsmVnBs2LwrthnFzEJYFTw2HzhYMmjnD2GtG6W2r2S2SvonCv} {Amount:320000000 RCDHash:6a437b1475d9455e8447f7b2a7f32044a28f5f16486d2f239eca5bdba02030c8 Address:FA2msvDAoVgzRx8BTmxFAYDLbg2VQXqhi2HzKQHmsb4mVrKjY4B6} {Amount:320000000 RCDHash:7e73ae9e7c31c632697e9c9207075a66f099f82f5d1da2aec157146d48c75533 Address:FA2vmboi6PbPHdGjqG5PfRhCG1hcpkXqNkVigAmmjq9atUAA2NpZ} {Amount:192000000 RCDHash:edef61cc4d07e34b64376c8ff5785274f84f191ae22224e90c8119d73727f3ce Address:FA3msHkoAH78cAVvdJE4Za6uSatPQR2aTgvSViRFN3vLBsixvkZQ} {Amount:480000000 RCDHash:665650f5cfd74ec95bac1bc823dc7b7ab5b388a3b0ba31663cb678955e8146aa Address:FA2k9d61ujVHRRMkajk1pKteRSaqGUKf3iJyCBEbU6HeWe2sC5nx} {Amount:320000000 RCDHash:cf681312cc74d91691e6c1be0df58c638145d877c6f1647c6ca8d88d2ffbfd17 Address:FA3YRUjaGJjpjvNZPW7CCD7Ba7bJne25HdrTainPYotNw4rUoh46} {Amount:640000000 RCDHash:cc26b2335e9b7c60bfd0e0e98d07ec7f58e67d54fb5717b86bbb868584ca1243 Address:FA3WzKn5ygD8E2uGocAYhaooeQyehSjq1HC3hSb2EaJ4ZGfjku63} {Amount:320000000 RCDHash:53c597f02efd7ef3caad48182969236a70883bada570aa316bc9b20efedcc73f Address:FA2byPxs4XYmra4Z6t3UcDwGaNP62LM631QarrqvVbrbsy9XCGoX}] ECOutputs:[]} {TxID:3a1e8dc38ef4112bc3110ae47a02c417ba465a5478bf5b97a9b4fc842a9ce67a DBHeight:0 Status:TransactionACK Fees:12000 Inputs:[{Amount:212000 RCDHash:d2e2860610e282b6d8d9fed05e2a8dce5d8211d86ca14e2edf05023f0759be97 Address:FA3ZxKyN3HHoJftdGbFp5PRvi12jPvQ3SgGNTDQya2D5jwFrtLqZ}] Outputs:[] ECOutputs:[{Amount:200000 RCDHash:3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29 Address:EC2DKSYyRcNWf7RS963VFYgMExoHRYLHVeCfQ9PGPmNzwrcmgm2r}]} {TxID:0b3f7feadcc849c60bdad4ccac4b831039c6321cecb6667a8d39a8c14850e5cc DBHeight:0 Status:TransactionACK Fees:12000 Inputs:[{Amount:500012000 RCDHash:d2e2860610e282b6d8d9fed05e2a8dce5d8211d86ca14e2edf05023f0759be97 Address:FA3ZxKyN3HHoJftdGbFp5PRvi12jPvQ3SgGNTDQya2D5jwFrtLqZ}] Outputs:[{Amount:500000000 RCDHash:646f3e8750c550e4582eca5047546ffef89c13a175985e320232bacac81cc428 Address:FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q}] ECOutputs:[]}]
want =
[{TxID:5d87f2ba00ebaee1b0aac86b97ab5a8d4ab5f07a948966856f5723b15c57a5ab Status:TransactionACK Fees:0 Inputs:[] Outputs:[{Amount:320000000 RCDHash:d06f8b5d84395afbec25d3aa3f3f2d5a6573ebd30e4d02e797d77107395c2b4a Address:FA3YsmVnBs2LwrthnFzEJYFTw2HzhYMmjnD2GtG6W2r2S2SvonCv} {Amount:576000000 RCDHash:e8e41a1c7ca7c29dc928e509cae82cae1a4711eb12fddc8bde25bf1733069efc Address:FA3jeSpDq6JSNmizDS8TWwdxKS9EiKFeRCXyZNYrfH6eqX1K9o8u} {Amount:320000000 RCDHash:6a437b1475d9455e8447f7b2a7f32044a28f5f16486d2f239eca5bdba02030c8 Address:FA2msvDAoVgzRx8BTmxFAYDLbg2VQXqhi2HzKQHmsb4mVrKjY4B6} {Amount:320000000 RCDHash:2b20273033acf00b40e88848a853a56dd0543570f4f28d30b050634d1e28bd6e Address:FA2J59Eb8xyizJLachFn8LuRXVsSNkoW2uPKrna8X4UrtyVwztgY} {Amount:320000000 RCDHash:53c597f02efd7ef3caad48182969236a70883bada570aa316bc9b20efedcc73f Address:FA2byPxs4XYmra4Z6t3UcDwGaNP62LM631QarrqvVbrbsy9XCGoX} {Amount:320000000 RCDHash:8f3064f2d1b8fac099719de1651e81c0fc3f0f29ef1a95a3b46c90e628b51ccc Address:FA3498SdD2tDAi2485czk6shCfU5Q3PC5Wsui6sNzxi1dTpwxpFj} {Amount:320000000 RCDHash:d06f8b5d84395afbec25d3aa3f3f2d5a6573ebd30e4d02e797d77107395c2b4a Address:FA3YsmVnBs2LwrthnFzEJYFTw2HzhYMmjnD2GtG6W2r2S2SvonCv} {Amount:320000000 RCDHash:6a437b1475d9455e8447f7b2a7f32044a28f5f16486d2f239eca5bdba02030c8 Address:FA2msvDAoVgzRx8BTmxFAYDLbg2VQXqhi2HzKQHmsb4mVrKjY4B6} {Amount:320000000 RCDHash:7e73ae9e7c31c632697e9c9207075a66f099f82f5d1da2aec157146d48c75533 Address:FA2vmboi6PbPHdGjqG5PfRhCG1hcpkXqNkVigAmmjq9atUAA2NpZ} {Amount:192000000 RCDHash:edef61cc4d07e34b64376c8ff5785274f84f191ae22224e90c8119d73727f3ce Address:FA3msHkoAH78cAVvdJE4Za6uSatPQR2aTgvSViRFN3vLBsixvkZQ} {Amount:480000000 RCDHash:665650f5cfd74ec95bac1bc823dc7b7ab5b388a3b0ba31663cb678955e8146aa Address:FA2k9d61ujVHRRMkajk1pKteRSaqGUKf3iJyCBEbU6HeWe2sC5nx} {Amount:320000000 RCDHash:cf681312cc74d91691e6c1be0df58c638145d877c6f1647c6ca8d88d2ffbfd17 Address:FA3YRUjaGJjpjvNZPW7CCD7Ba7bJne25HdrTainPYotNw4rUoh46} {Amount:640000000 RCDHash:cc26b2335e9b7c60bfd0e0e98d07ec7f58e67d54fb5717b86bbb868584ca1243 Address:FA3WzKn5ygD8E2uGocAYhaooeQyehSjq1HC3hSb2EaJ4ZGfjku63} {Amount:320000000 RCDHash:53c597f02efd7ef3caad48182969236a70883bada570aa316bc9b20efedcc73f Address:FA2byPxs4XYmra4Z6t3UcDwGaNP62LM631QarrqvVbrbsy9XCGoX}] ECOutputs:[]} {TxID:3a1e8dc38ef4112bc3110ae47a02c417ba465a5478bf5b97a9b4fc842a9ce67a Status:TransactionACK Fees:12000 Inputs:[{Amount:212000 RCDHash:d2e2860610e282b6d8d9fed05e2a8dce5d8211d86ca14e2edf05023f0759be97 Address:FA3ZxKyN3HHoJftdGbFp5PRvi12jPvQ3SgGNTDQya2D5jwFrtLqZ}] Outputs:[] ECOutputs:[{Amount:200000 RCDHash:3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29 Address:EC2DKSYyRcNWf7RS963VFYgMExoHRYLHVeCfQ9PGPmNzwrcmgm2r}]} {TxID:0b3f7feadcc849c60bdad4ccac4b831039c6321cecb6667a8d39a8c14850e5cc Status:TransactionACK Fees:12000 Inputs:[{Amount:500012000 RCDHash:d2e2860610e282b6d8d9fed05e2a8dce5d8211d86ca14e2edf05023f0759be97 Address:FA3ZxKyN3HHoJftdGbFp5PRvi12jPvQ3SgGNTDQya2D5jwFrtLqZ}] Outputs:[{Amount:500000000 RCDHash:646f3e8750c550e4582eca5047546ffef89c13a175985e320232bacac81cc428 Address:FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q}] ECOutputs:[]}]
FAIL
exit status 1
It looks like it's the DBHeight: 0
missing, not sure if it's a test problem or an actual bug?
The APICounter is not thread safe and generates a warning by the Golang race condition detector:
WARNING: DATA RACE
Read at 0x00c00015e678 by goroutine 32:
github.com/FactomProject/factom.newCounter.func1()
/home/paul/go/pkg/mod/github.com/!factom!project/[email protected]/jsonrpc.go:359 +0x4a
github.com/FactomProject/factom.GetCurrentMinute()
/home/paul/go/pkg/mod/github.com/!factom!project/[email protected]/currentminute.go:46 +0x4d
Previous write at 0x00c00015e678 by goroutine 44:
github.com/FactomProject/factom.newCounter.func1()
/home/paul/go/pkg/mod/github.com/!factom!project/[email protected]/jsonrpc.go:359 +0x60
github.com/FactomProject/factom.GetDBlockByHeight()
/home/paul/go/pkg/mod/github.com/!factom!project/[email protected]/dblock.go:109 +0x5b
Current implementation: https://github.com/FactomProject/factom/blob/master/jsonrpc.go#L331
It most likely has a very little or no actual impact, but having the warning show up for people using the factom lib is unnecessary noise. Golang provides out of the box some primitive for atomic counters that could be leveraged: https://gobyexample.com/atomic-counters
Version # proposal: v0.4.0 (currently we're at v0.3.6)
I added most of the sensible open PRs and issues to the the board. Most of these are ready to be reviewed but some still need more work, mainly the go.mod one.
There are two PRs that need special attention:
We should decide if we should include these now and they just aren't useful until their counterparts are enabled, or wait until integration is done on the other side and then make another release.
Recently, we tried to use factom.SignData()
to make a signature for the project.
But, it returned runtime panic error.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x1376423]
Here is factom version we used:
github.com/FactomProject/factom v0.3.6-0.20200826003247-4751d0f52dda
github.com/FactomProject/factomd v6.3.2+incompatible
Is there any known issue why this runtime panic error is happening when try to sign data to generate signature?
Here is code snipped we used.
func (spr *StakingPriceRecord) CreateSPREntry() (*factom.Entry, error) {
e := new(factom.Entry)
e.ChainID = hex.EncodeToString(base58.Decode(spr.SPRChainID))
rcd, err := common.ConvertFCTtoRaw(spr.CoinbaseAddress)
if err != nil {
return nil, err
}
e.Content, err = spr.SafeMarshal()
if err != nil {
return nil, err
}
signature, errS := factom.SignData(spr.CoinbaseAddress, e.Content)
if errS != nil {
return nil, err
}
pubKey := signature.PubKey
sign := signature.Signature
signData := append(pubKey, sign...)
e.ExtIDs = [][]byte{{spr.Version}, rcd, signData}
return e, nil
}
factom.SignData() returns panic error now.
Thank you in advance.
See factom.js implementation for sample: https://github.com/PaulBernier/factomjs
At the least, linking to: https://godoc.org/github.com/FactomProject/factomd
I am using the code of branch v1-rollup
commit 5edf7247fc876772bed5c68eb78dd4f8e3292b24
(latest at the time of writing).
The GetCurrentMinute
method returns the Minute
of the block currently being built together with a DirectoryBlockHeight
but that DB height is the one of the last saved block and not the block currently being built, which is misleading. I believe it should also be the height of the block being currently built to be conistent.
As the name already implies, the big change is that this version finally moves away from glide and introduces go.mod. This release also contains some breaking changes for retrieving blocks and transactions.
The factomd API methods for block retrieval typically return both a json representation as well as the raw factom marshalled bytes of the block. There are very few applications where you need both the unmarshalled block and the raw bytes at the same time. You either need the unmarshalled data only, or if you need the raw bytes, you can unmarshal it locally. Transmitting both at the same time wastes bandwidth if only one is used.
The new factomd version (6.9.0-Wax) adds a new parameter to these API methods ("noraw") that allows us to retrieve the unmarshalled data without the raw. To get the raw data only, we can use the separate "get-raw" endpoint. The client now reflects this and the common block retrieval methods no longer return the raw data:
GetABlock(string) (*ABlock, []byte, error)
=> GetABlock(string) (*ABlock, error)
GetABlockByHeight(int64) (*ABlock, []byte, error)
=> GetABlockByHeight(int64) (*ABlock, error)
GetDBlock(string) (*DBlock, []byte, error)
=> GetDBlock(string) (*DBlock, error)
GetDBlockByHeight(int64) (*DBlock, []byte, error)
=> GetDBlockByHeight(int64) (*DBlock, error)
GetECBlock(string) (*ECBlock, []byte, error)
=> GetECBlock(string) (*ECBlock, error)
GetECBlockByHeight(int64) (*ECBlock, []byte, error)
=> GetECBlockByHeight(int64) (*ECBlock, error)
GetFBlock(string) (*FBlock, []byte, error)
=> GetFBlock(string) (*FBlock, error)
GetFBlockByHeight(int64) (*FBlock, []byte, error)
=> GetFBlockByHeight(int64) (*FBlock, error)
To retrieve the raw data for these blocks, use:
The client now supports the "anchors" API endpoint via the following two functions:
GetAnchors(hash string) (*Anchors, error)
GetAnchorsByHeight(height int64) (*Anchors, error)
The Anchors
struct contains the height, keymr, as well as a potential Bitcoin or Ethereum anchor. Not all blocks have anchors and they are nil
if missing:
Lines 12 to 37 in afafc3a
Instead of returning the raw json response as a string, the client now unmarshals the pending entries and transactions:
GetPendingEntries() (string, error)
=> GetPendingEntries() ([]PendingEntry, error)
GetPendingTransactions() (string, error)
=> GetPendingTransactions() ([]PendingTransaction, error)
The FBlock structure now contains the unmarshalled list of transactions rather than the raw json response. FBlock.Transactions is of type "FBTransaction" which contains the txid, height, timestamp, signed input transactions, and the fct/ec outputs:
Lines 29 to 57 in afafc3a
The open node is a cluster of nodes that sit behind a load balancer. Sometimes this can cause issues with slightly inconsistent data between calls. The open node has enabled cookie sessions which ensure that all requests in the same session target the same node. There are two ways you can use this:
factom.SetOpenNode()
This call will set the factomd endpoint to the open node and enable the cookie jar.
factom.EnableCookies()
This enables cookies but does not change the factomd endpoint. You can also use this to reset cookies.
EntryCommitMessage(e *Entry, ec *ECAddress) (*bytes.Buffer, error)
has been made public. It returns the raw bytes of what would be sent to factomd when using the ComposeEntryCommit
function, allowing you to build commits without sending them.I was tasked to investigate why the "Transactions" page is fairly slow to load, and I tracked down the error to the GetTXRange
function:
Lines 207 to 216 in 27c6cd7
In order to get a range of transactions by height, the code first gets every single transaction via txs, err := db.GetAllTXs()
(by scanning through all 170k+ Factoid Blocks) and then loops through all transactions to filter out the ones with the desirable height. This is obviously not very efficient and caused the function GetRelatedTransactions
to perform very poorly, taking an average of ~5seconds to execute on my pc.
This function locks a mutex.
https://github.com/FactomProject/enterprise-wallet/blob/7819099c274a1bedaa9d677371c0b29079931f2a/wallet/walletDB.go#L390-L391
The mutex remains locked as long as the function runs in the background and it's automatically scheduled to execute every 10 seconds, which prevented the "Transactions" page from loading as it waited for that mutex to be released.
This can be fixed by rewriting the GetTxRange
function to only cycle from the head down to the desired height and grabbing the related transactions instead of all 170k+ factoid blocks, which drove down execution time to ~250ms on my pc.
Proposed fix: WhoSoup@e0e9e5d
(note: the new code is substantially copy/pasted from GetAllTxs
)
Suddenly, factom.GetTransaction()
doesn't return error on incorrect hash as input.
Reproduce this request using non-existing tx hash:
factomTx, err := factom.GetTransaction("0129b5e26e40a11e58bbc91722bc1b021b1c38ca084965ce09b25dd33aa7c891")
log.Info(factomTx)
log.Fatal(err)
Result:
INFO[0001] &{<nil> <nil> <nil> -1}
FATA[0001] <nil>
Thanks to @ilzheev for reporting this one.
Regular transactions contain the RCD/Signature for all inputs but pending transactions currently don't. They're not returned by the API so this will need modification to factomd as well.
Todo:
Once factomd diagnostics API will be finalized, I suggest to add GetDiagnostics()
call into factom Go client.
Re-apply the work done in: #133
on handle compose-chain: should return these errors
if cost, err := factom.EntryCost(&e); err != nil {
newCustomInternalError(err.Error())
} else if balance < int64(cost) {
newCustomInternalError("Not enough Entry Credits")
}
In factomd:v6.4.3 new API call appeared:
https://docs.factom.com/api#anchors
Retrieve information about the directory block anchors that have been confirmed on Bitcoin and Ethereum.
Parameter options: - "height" - the directory block height (integer) to request anchors for - "hash" - the object’s hash (hex string) to request anchors for (e.g. entry hash, entry block keymr, factoid block keymr, admin block lookup hash, entry credit block header hash, or directory block keymr)
I suggest to add 2 functions into factom lib:
GetAnchors(hash string)
and GetAnchorsByHeight(height int64)
Hi
I need help.
I have factoid address generated from private key by this command.
$ curl -X GET "http://localhost:8089/v1/factoid-generate-address-from-private-key/?name=addr001&privateKey=85d6755c286c6f139b1696ca74b0c14da473beadc37b2ec6273f2a92ce8d7c88"
in this page https://www.factom.com/devs/docs/guide/factoid-api-reference
But I cant find api for private key in new version wallet.
https://docs.factom.com/api#address
What is alternate api for "factoid-generate-address-from-private-key", and how to generate factoid address from private key?
Regards
Hi.
This it's not a issue, it's only for ask to us about factom and it's possible to use to encrypt and decrypt data using factom? can i use the api for that purpose? or in all cases the data goes to a blockchain?
Regards
ER
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.