RecordsKeeperRubyLib 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -1
  3. data/CODE_OF_CONDUCT.md +0 -8
  4. data/Gemfile +0 -1
  5. data/Gemfile.lock +4 -62
  6. data/LICENSE.txt +2 -2
  7. data/README.md +92 -1
  8. data/{RecordsKeeperRuby.gemspec → RecordsKeeperRubyLib.gemspec} +4 -5
  9. data/bin/console +1 -1
  10. data/config.yaml +8 -0
  11. data/docs/{addressdoc.rb → address_doc.rb} +105 -116
  12. data/docs/{assetsdoc.rb → asset_doc.rb} +54 -65
  13. data/docs/block_doc.rb +63 -0
  14. data/docs/blockchain_doc.rb +77 -0
  15. data/docs/{permissionsdoc.rb → permissions_doc.rb} +54 -65
  16. data/docs/{streamdoc.rb → stream_doc.rb} +79 -84
  17. data/docs/{transactiondoc.rb → transaction_doc.rb} +110 -121
  18. data/docs/{walletdoc.rb → wallet_doc.rb} +122 -133
  19. data/lib/RecordsKeeperRubyLib.rb +9 -0
  20. data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/address.rb +198 -186
  21. data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/assets.rb +99 -87
  22. data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/block.rb +94 -89
  23. data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/blockchain.rb +148 -135
  24. data/lib/RecordsKeeperRubyLib/config.yaml +8 -0
  25. data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/permissions.rb +77 -77
  26. data/lib/RecordsKeeperRubyLib/stream.rb +220 -0
  27. data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/transaction.rb +213 -182
  28. data/lib/RecordsKeeperRubyLib/version.rb +3 -0
  29. data/lib/{RecordsKeeperRuby → RecordsKeeperRubyLib}/wallet.rb +263 -252
  30. data/lib/config.yaml +8 -0
  31. metadata +27 -41
  32. data/docs/blockchaindoc.rb +0 -77
  33. data/docs/blockdoc.rb +0 -76
  34. data/lib/RecordsKeeperRuby.rb +0 -9
  35. data/lib/RecordsKeeperRuby/sample_config.yaml +0 -60
  36. data/lib/RecordsKeeperRuby/stream.rb +0 -169
  37. data/lib/RecordsKeeperRuby/version.rb +0 -3
  38. data/lib/sample_config.yaml +0 -60
  39. 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
- # cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
18
- # * Set a *network* value to change the network-type
19
- # network = cfg['testnet'] # Network variable to store the network that you want to access
20
- # **NOTE:* Default network is *Test-net*, you can change it to mainnet or testnet
21
- # Check the network type for url and chain name:
22
- # if @network==cfg['testnet']
23
- # @url = cfg['testnet']['url']
24
- # @chain = cfg['testnet']['chain']
25
- # else
26
- # @url = cfg['mainnet']['url']
27
- # @chain = cfg['mainnet']['chain']
28
- # end
29
- # -------------------
30
- # == Node Authentication
31
- # Import values from config file.
32
- # * User name: The rpc user is used to call the APIs.
33
- # * Password: The rpc password is used to authenticate the APIs.
34
- # * Check the network type for username and password:
35
- # if @network==cfg['testnet']
36
- # @user = cfg['testnet']['rkuser']
37
- # @password = cfg['testnet']['passwd']
38
- # else
39
- # @user = cfg['mainnet']['rkuser']
40
- # @password = cfg['mainnet']['passwd']
41
- # end
42
- # Now we have node authentication credentials.
43
- # ------------
44
- # = class Assets
45
- # Assets class is used to call assets related functions like create assets and list assets functions which are used on the RecordsKeeeper Blockchain.
46
- # === 1. createAsset
47
- # This function is used to create or issue an asset.
48
- # txid = createAsset # Function call
49
- #
50
- # puts txid # prints tx id of the issued asset
51
- # === 2. retrieveAssets
52
- # This function is used to list all assets, no of assets, issued quantity and issued transaction id of all the assets on RecordsKeeper Blockchain.
53
- # asset_name, issue_id, issue_qty, asset_count = retrieveAssets # Function call
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
- # cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
18
- # * Set a *network* value to change the network-type
19
- # network = cfg['testnet'] # Network variable to store the network that you want to access
20
- # **NOTE:* Default network is *Test-net*, you can change it to mainnet or testnet
21
- # Check the network type for url and chain name:
22
- # if @network==cfg['testnet']
23
- # @url = cfg['testnet']['url']
24
- # @chain = cfg['testnet']['chain']
25
- # else
26
- # @url = cfg['mainnet']['url']
27
- # @chain = cfg['mainnet']['chain']
28
- # end
29
- # -------------------
30
- # == Node Authentication
31
- # Import values from config file.
32
- # * User name: The rpc user is used to call the APIs.
33
- # * Password: The rpc password is used to authenticate the APIs.
34
- # * Check the network type for username and password:
35
- # if @network==cfg['testnet']
36
- # @user = cfg['testnet']['rkuser']
37
- # @password = cfg['testnet']['passwd']
38
- # else
39
- # @user = cfg['mainnet']['rkuser']
40
- # @password = cfg['mainnet']['passwd']
41
- # end
42
- # Now we have node authentication credentials.
43
- # ------------
44
- # = class Permissions
45
- # 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.
46
- # === 1. grantPermission address, permissions
47
- # This function is used to grant permissions like connect, send, receive, create, issue, mine, activate, admin to an address on RecordsKeeper Blockchain.
48
- #
49
- # You have to pass these two arguments to the grantPermission function call:
50
- # * Permissions: list of comma-seperated permissions passed as a string
51
- # * Address: to which you have to grant permission
52
- # result = grantPermission address, permissions
53
- #
54
- # puts txid # prints response of the grant permision transaction
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
- # require 'hex_string'
13
- # -----------------
14
- # == Create Connection
15
- # Entry point for accessing Blockchain class resources.
16
- # * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
17
- # * Chain-name: Name of the chain
18
- # cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
19
- # * Set a *network* value to change the network-type
20
- # network = cfg['testnet'] # Network variable to store the network that you want to access
21
- # **NOTE:* Default network is *Test-net* ( i.e., you can set it to either testnet or mainnet).
22
- # Check the network type for url and chain name:
23
- # if @network==cfg['testnet']
24
- # @url = cfg['testnet']['url']
25
- # @chain = cfg['testnet']['chain']
26
- # else
27
- # @url = cfg['mainnet']['url']
28
- # @chain = cfg['mainnet']['chain']
29
- # end
30
- # -------------------
31
- # == Node Authentication
32
- # Import values from config file.
33
- # * User name: The rpc user is used to call the APIs.
34
- # * Password: The rpc password is used to authenticate the APIs.
35
- # * Check the network type for username and password:
36
- # if @network==cfg['testnet']
37
- # @user = cfg['testnet']['rkuser']
38
- # @password = cfg['testnet']['passwd']
39
- # else
40
- # @user = cfg['mainnet']['rkuser']
41
- # @password = cfg['mainnet']['passwd']
42
- # end
43
- # Now we have node authentication credentials.
44
- # ------------
45
- # = class Stream
46
- # 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.
47
- # === 1. publish address, stream, key, data
48
- # This function retrieves information about the chain.
49
- # publish address, stream, key, data
50
- # transacid = publish address, stream, key, data # Function call
51
- #
52
- # puts transacid # Prints txid.
53
- # === 2. retrieve stream, txid
54
- # This function retrieves information related to your node.
55
- # retrieve stream, txid
56
- # data = retrieve stream, txid # Function call
57
- #
58
- # puts data # Prints raw_data.
59
- # === 3. retrieveWithAddress stream, address
60
- # This function lists all the permissions.
61
- # retrieveWithAddress stream, address
62
- # retadd = retrieveWithAddress stream, address # Function call
63
- #
64
- # puts retadd # Prints key, data and txid.
65
- # === 4. retrieveWithKey stream, key
66
- # This function retrieves information related to your node.
67
- # retrieveWithKey stream, key
68
- # retkey = retrieveWithKey stream, key # Function call
69
- #
70
- # puts retkey # Prints publisher, data and txid.
71
- # === 5. verifyData stream, data, count
72
- # This function retrieves information related to your node.
73
- # verifyData stream, data, count
74
- # verifystat = verifyData stream, data, count # Function call
75
- #
76
- # puts verifystat # Prints result.
77
- # === 6. retrieveItems stream, count
78
- # This function retrieves information related to your node.
79
- # retrieveItems stream, count
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