RecordsKeeperRubyLib 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/CODE_OF_CONDUCT.md +0 -8
- data/Gemfile +0 -1
- data/Gemfile.lock +4 -62
- data/LICENSE.txt +2 -2
- data/README.md +92 -1
- data/{RecordsKeeperRuby.gemspec → RecordsKeeperRubyLib.gemspec} +4 -5
- data/bin/console +1 -1
- data/config.yaml +8 -0
- data/docs/{addressdoc.rb → address_doc.rb} +105 -116
- data/docs/{assetsdoc.rb → asset_doc.rb} +54 -65
- data/docs/block_doc.rb +63 -0
- data/docs/blockchain_doc.rb +77 -0
- data/docs/{permissionsdoc.rb → permissions_doc.rb} +54 -65
- data/docs/{streamdoc.rb → stream_doc.rb} +79 -84
- data/docs/{transactiondoc.rb → transaction_doc.rb} +110 -121
- data/docs/{walletdoc.rb → wallet_doc.rb} +122 -133
- data/lib/RecordsKeeperRubyLib.rb +9 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/address.rb +198 -186
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/assets.rb +99 -87
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/block.rb +94 -89
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/blockchain.rb +148 -135
- data/lib/RecordsKeeperRubyLib/config.yaml +8 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/permissions.rb +77 -77
- data/lib/RecordsKeeperRubyLib/stream.rb +220 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/transaction.rb +213 -182
- data/lib/RecordsKeeperRubyLib/version.rb +3 -0
- data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/wallet.rb +263 -252
- data/lib/config.yaml +8 -0
- metadata +27 -41
- data/docs/blockchaindoc.rb +0 -77
- data/docs/blockdoc.rb +0 -76
- data/lib/RecordsKeeperRuby.rb +0 -9
- data/lib/RecordsKeeperRuby/sample_config.yaml +0 -60
- data/lib/RecordsKeeperRuby/stream.rb +0 -169
- data/lib/RecordsKeeperRuby/version.rb +0 -3
- data/lib/sample_config.yaml +0 -60
- data/sample_config.yaml +0 -60
@@ -1,65 +1,54 @@
|
|
1
|
-
# = Assets Class Usage
|
2
|
-
# This is a library to work with RecordsKeeper assets.
|
3
|
-
# You can create new assets and list all assets by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
-
# ---------
|
5
|
-
# == Libraries
|
6
|
-
# Require these ruby libraries first to get started with the functionality.
|
7
|
-
# require 'rubygems'
|
8
|
-
# require 'httparty'
|
9
|
-
# require 'json'
|
10
|
-
# require 'binary_parser'
|
11
|
-
# require 'yaml'
|
12
|
-
# -----------------
|
13
|
-
# == Create Connection
|
14
|
-
# Entry point for accessing Address class resources.
|
15
|
-
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
-
# * Chain-name: chain name
|
17
|
-
#
|
18
|
-
# * Set a *network* value
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
# puts asset_name # prints all the addresses of the wallet
|
56
|
-
# puts asset_count # prints the address count
|
57
|
-
# puts issue_qty # prints assets issued quantity
|
58
|
-
# puts issue_id # prints assets issued transaction id
|
59
|
-
# === 3. sendAsset
|
60
|
-
# This function is used to send an asset.
|
61
|
-
# txid = sendAsset # Function call
|
62
|
-
#
|
63
|
-
# puts txid # prints tx id of the sent asset
|
64
|
-
class Assets
|
65
|
-
end
|
1
|
+
# = Assets Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper assets.
|
3
|
+
# You can create new assets and list all assets by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Assets
|
34
|
+
# Assets class is used to call assets related functions like create assets and list assets functions which are used on the RecordsKeeeper Blockchain.
|
35
|
+
# === 1. createAsset
|
36
|
+
# This function is used to create or issue an asset.
|
37
|
+
# txid = createAsset address, asset_name, asset_qty # Function call
|
38
|
+
#
|
39
|
+
# puts txid # prints tx id of the issued asset
|
40
|
+
# === 2. retrieveAssets
|
41
|
+
# This function is used to list all assets, no of assets, issued quantity and issued transaction id of all the assets on RecordsKeeper Blockchain.
|
42
|
+
# retrievedinfo = JSON.parse retrieveAssets # Function call
|
43
|
+
#
|
44
|
+
# puts retrievedinfo['asset_name'] # prints all the addresses of the wallet
|
45
|
+
# puts retrievedinfo['asset_count'] # prints the address count
|
46
|
+
# puts retrievedinfo['issue_qty'] # prints assets issued quantity
|
47
|
+
# puts retrievedinfo['issue_id'] # prints assets issued transaction id
|
48
|
+
# === 3. sendAsset
|
49
|
+
# This function is used to send an asset.
|
50
|
+
# txid = sendAsset address, asset_name, asset_qty # Function call
|
51
|
+
#
|
52
|
+
# puts txid # prints tx id of the sent asset
|
53
|
+
class Assets
|
54
|
+
end
|
data/docs/block_doc.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# = Block Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper block information.
|
3
|
+
# You can generate new address, check all addresses, check address validity, check address permissions, check address balance by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Block
|
34
|
+
# Block class is used to call block related functions like blockinfo which is used to retrieve block details
|
35
|
+
# like block's hash value, size, nonce, transaction ids, transaction count, miner address, previous block hash,
|
36
|
+
# next block hash, merkleroot, blocktime and difficulty of the block for which you have made the query.
|
37
|
+
# === 1. blockinfo block_height
|
38
|
+
# * You have to pass the block height as an argument in the blockinfo function call (Block height: Height of the block of which you want to collect information.)
|
39
|
+
# * It will return transaction ids, transaction count, nonce, size, hash value, previous block's hash value, next block hash value, merkle root, difficulty, blocktime and miner address of the block.
|
40
|
+
# information = JSON.parse blockinfo block_height # Function call
|
41
|
+
#
|
42
|
+
# puts information['tx_count'] # prints transaction count of the block
|
43
|
+
# puts information['tx'] # prints transaction ids of the block
|
44
|
+
# puts information['size'] # prints size of the block
|
45
|
+
# puts information['blockHash'] # prints hash value of the block
|
46
|
+
# puts information['nonce'] # prints nonce of the block
|
47
|
+
# puts information['miner'] # prints miner's address of the block
|
48
|
+
# puts information['nextblock'] # prints next block's hash
|
49
|
+
# puts information['prevblock'] # prints previous block's hash
|
50
|
+
# puts information['merkleroot'] # prints merkle root of the block
|
51
|
+
# puts information['blocktime'] # prints time at which block is mined
|
52
|
+
# puts information['difficulty'] # prints difficulty of the block
|
53
|
+
# === 2. retrieveBlocks block_range
|
54
|
+
# * You have to pass the block's height as the argument to the retrieveBlocks function call (Block range: Range of the block of which you want to collect information)
|
55
|
+
# * It will return blockhash, miner address, blocktime and transaction count of the blocks.
|
56
|
+
# information = JSON.parse retrieveBlocks block_range # Function call
|
57
|
+
#
|
58
|
+
# puts information['block_hash'] # prints hash of the blocks
|
59
|
+
# puts information['miner_add'] # prints miner of the blocks
|
60
|
+
# puts information['block_time'] # prints block time of the blocks
|
61
|
+
# puts information['txcount'] # prints transaction count of the blocks
|
62
|
+
class Block
|
63
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# = Blockchain Class Usage
|
2
|
+
# This is a library to work with Blockchains in RecordsKeeper.
|
3
|
+
# You can retrieve information about the chain and node, list all the permissions and the pending transactions and check your node's balance.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Blockchain
|
34
|
+
# Blockchain class is used to call blockchain related functions to retrieve information about the chain and node, list all the permissions and the pending transactions and check your node's balance.
|
35
|
+
# === 1. getChainInfo
|
36
|
+
# This function retrieves information about the chain.
|
37
|
+
# getChainInfo
|
38
|
+
# chainInfo = JSON.parse getChainInfo # Function call
|
39
|
+
#
|
40
|
+
# puts chainInfo['chain_protocol'] # prints chain-protocol
|
41
|
+
# puts chainInfo['chain_description'] # prints chain-description
|
42
|
+
# puts chainInfo['root_stream'] # prints root-stream-name
|
43
|
+
# puts chainInfo['max_blocksize'] # prints maximum-block-size
|
44
|
+
# puts chainInfo['default_networkport'] # prints default-network-port
|
45
|
+
# puts chainInfo['default_rpcport'] # prints default-rpc-port
|
46
|
+
# puts chainInfo['mining_diversity'] # prints mining-diversity
|
47
|
+
# puts chainInfo['chain_name'] # prints chain-name
|
48
|
+
# === 2. getNodeInfo
|
49
|
+
# This function retrieves information related to your node.
|
50
|
+
# getNodeInfo
|
51
|
+
# nodeInfo = JSON.parse getNodeInfo # Function call
|
52
|
+
#
|
53
|
+
# puts nodeInfo['node_balance'] # prints balance
|
54
|
+
# puts nodeInfo['synced_blocks'] # prints synced-blocks
|
55
|
+
# puts nodeInfo['node_address'] # prints nodeaddress
|
56
|
+
# puts nodeInfo['difficulty'] # prints difficulty
|
57
|
+
# === 3. permissions
|
58
|
+
# This function lists all the permissions.
|
59
|
+
# permissions
|
60
|
+
# listpermissions = permissions # Function call
|
61
|
+
#
|
62
|
+
# puts listpermissions # Prints the list of permissions.
|
63
|
+
# === 4. getpendingTransactions
|
64
|
+
# This function retrieves information related to your node.
|
65
|
+
# getpendingTransactions
|
66
|
+
# pentransac = JSON.parse getpendingTransactions # Function call
|
67
|
+
#
|
68
|
+
# puts pentransac['tx_count'] # prints transaction count
|
69
|
+
# puts pentransac['tx'] # prints the pending transactions
|
70
|
+
# === 5. checkNodeBalance
|
71
|
+
# This function retrieves information related to your node.
|
72
|
+
# checkNodeBalance
|
73
|
+
# nodeBal = checkNodeBalance # Function call
|
74
|
+
#
|
75
|
+
# puts nodeBal # Prints node's balance amount.
|
76
|
+
class Blockchain
|
77
|
+
end
|
@@ -1,65 +1,54 @@
|
|
1
|
-
# = Permissions Class Usage
|
2
|
-
# This is a library to work with RecordsKeeper permissions.
|
3
|
-
# You can grant and revoke permissions like connect, send, receive, create, issue, mine, activate, admin by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
-
# ---------
|
5
|
-
# == Libraries
|
6
|
-
# Require these ruby libraries first to get started with the functionality.
|
7
|
-
# require 'rubygems'
|
8
|
-
# require 'httparty'
|
9
|
-
# require 'json'
|
10
|
-
# require 'binary_parser'
|
11
|
-
# require 'yaml'
|
12
|
-
# -----------------
|
13
|
-
# == Create Connection
|
14
|
-
# Entry point for accessing Address class resources.
|
15
|
-
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
-
# * Chain-name: chain name
|
17
|
-
#
|
18
|
-
# * Set a *network* value
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
# result
|
53
|
-
|
54
|
-
|
55
|
-
# === 2. revokePermission address, permissions
|
56
|
-
# This function is used to revoke permissions like connect, send, receive, create, issue, mine, activate, admin to an address on RecordsKeeper Blockchain.
|
57
|
-
#
|
58
|
-
# You have to pass these two arguments to the grantPermission function call:
|
59
|
-
# * Permissions: list of comma-seperated permissions passed as a string
|
60
|
-
# * Address: to which you have to grant permission
|
61
|
-
# result = revokePermission address, permissions
|
62
|
-
#
|
63
|
-
# puts result # prints response of the revoke permision transaction
|
64
|
-
class Permissions
|
65
|
-
end
|
1
|
+
# = Permissions Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper permissions.
|
3
|
+
# You can grant and revoke permissions like connect, send, receive, create, issue, mine, activate, admin by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Permissions
|
34
|
+
# Permissions class is used to call permissions related functions like grant and revoke permissions for an address functions which are used on the RecordsKeeeper Blockchain.
|
35
|
+
# === 1. grantPermission address, permissions
|
36
|
+
# This function is used to grant permissions like connect, send, receive, create, issue, mine, activate, admin to an address on RecordsKeeper Blockchain.
|
37
|
+
#
|
38
|
+
# You have to pass these two arguments to the grantPermission function call:
|
39
|
+
# * Permissions: list of comma-seperated permissions passed as a string
|
40
|
+
# * Address: to which you have to grant permission
|
41
|
+
# result = grantPermission address, permissions
|
42
|
+
#
|
43
|
+
# puts txid # prints response of the grant permision transaction
|
44
|
+
# === 2. revokePermission address, permissions
|
45
|
+
# This function is used to revoke permissions like connect, send, receive, create, issue, mine, activate, admin to an address on RecordsKeeper Blockchain.
|
46
|
+
#
|
47
|
+
# You have to pass these two arguments to the grantPermission function call:
|
48
|
+
# * Permissions: list of comma-seperated permissions passed as a string
|
49
|
+
# * Address: to which you have to grant permission
|
50
|
+
# result = revokePermission address, permissions
|
51
|
+
#
|
52
|
+
# puts result # prints response of the revoke permision transaction
|
53
|
+
class Permissions
|
54
|
+
end
|
@@ -1,84 +1,79 @@
|
|
1
|
-
# = Stream Class Usage
|
2
|
-
# This is a library to work with streams in RecordsKeeper Blockchain.
|
3
|
-
# You can publish address, retrieve data, retrieve with address, retrieve with key, verify data and retrieve items.
|
4
|
-
# ---------
|
5
|
-
# == Libraries
|
6
|
-
# Require these ruby libraries first to get started with the functionality.
|
7
|
-
# require 'rubygems'
|
8
|
-
# require 'httparty'
|
9
|
-
# require 'json'
|
10
|
-
# require 'binary_parser'
|
11
|
-
# require 'yaml'
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# *
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
# ===
|
48
|
-
# This function
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
# retitem = retrieveItems stream, count # Function call
|
81
|
-
#
|
82
|
-
# puts retitem # Prints address, key_value, raw_data and txid.
|
83
|
-
class Stream
|
84
|
-
end
|
1
|
+
# = Stream Class Usage
|
2
|
+
# This is a library to work with streams in RecordsKeeper Blockchain.
|
3
|
+
# You can publish address, retrieve data, retrieve with address, retrieve with key, verify data and retrieve items.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value.
|
19
|
+
# network = cfg['network'] # Network variable to store the network that you want to access
|
20
|
+
# * Set url and chain name:
|
21
|
+
# @url = cfg['network']['url']
|
22
|
+
# @chain = cfg['network']['chain']
|
23
|
+
# -------------------
|
24
|
+
# == Node Authentication
|
25
|
+
# Import values from config file.
|
26
|
+
# * User name: The rpc user is used to call the APIs.
|
27
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
28
|
+
# * Set the rpc username and password:
|
29
|
+
# @user = cfg['network']['rkuser']
|
30
|
+
# @password = cfg['network']['passwd']
|
31
|
+
# Now we have node authentication credentials.
|
32
|
+
# ------------
|
33
|
+
# = class Stream
|
34
|
+
# Stream class is used to call stream related functions to publish address, retrieve data, retrieve with address, retrieve with key, verify data and retrieve items.
|
35
|
+
# === 1. publish address, stream, key, data
|
36
|
+
# This function retrieves information about the chain.
|
37
|
+
# publish address, stream, key, data
|
38
|
+
# transacid = publish address, stream, key, data # Function call
|
39
|
+
#
|
40
|
+
# puts transacid # Prints txid.
|
41
|
+
# === 2. retrieve stream, txid
|
42
|
+
# This function retrieves information related to your node.
|
43
|
+
# retrieve stream, txid
|
44
|
+
# data = retrieve stream, txid # Function call
|
45
|
+
#
|
46
|
+
# puts data # Prints raw_data.
|
47
|
+
# === 3. retrieveWithAddress stream, address
|
48
|
+
# This function lists all the permissions.
|
49
|
+
# retrieveWithAddress stream, address
|
50
|
+
# retadd = JSON.parse retrieveWithAddress stream, address # Function call
|
51
|
+
#
|
52
|
+
# puts retadd['key'] # Prints key, data and txid.
|
53
|
+
# puts retadd['raw_data'] # prints raw data
|
54
|
+
# puts retadd['txid'] # prints transaction id
|
55
|
+
# === 4. retrieveWithKey stream, key
|
56
|
+
# This function retrieves information related to your node.
|
57
|
+
# retrieveWithKey stream, key
|
58
|
+
# retkey = JSON.parse retrieveWithKey stream, key # Function call
|
59
|
+
#
|
60
|
+
# puts retkey['publisher'] # prints publisher
|
61
|
+
# puts retkey['raw_data'] # prints raw data
|
62
|
+
# puts retkey['txid'] # prints transaction id
|
63
|
+
# === 5. verifyData stream, data, count
|
64
|
+
# This function retrieves information related to your node.
|
65
|
+
# verifyData stream, data, count
|
66
|
+
# verifystat = verifyData stream, data, count # Function call
|
67
|
+
#
|
68
|
+
# puts verifystat # Prints result.
|
69
|
+
# === 6. retrieveItems stream, count
|
70
|
+
# This function retrieves information related to your node.
|
71
|
+
# retrieveItems stream, count
|
72
|
+
# retitem = JSON.parse retrieveItems stream, count # Function call
|
73
|
+
#
|
74
|
+
# puts retitem['address'] # prints address
|
75
|
+
# puts retitem['key_value'] # prints key_value
|
76
|
+
# puts retitem['raw_data'] # prints raw_data
|
77
|
+
# puts retitem['txid'] # prints transaction id
|
78
|
+
class Stream
|
79
|
+
end
|