Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Add conditional logic to use getBlock rather than getBlockInfo. #130

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

opi-smccoole
Copy link
Contributor

getBlock is used for nodeos chains under 2.1.0 and getBlockInfo is used for 2.1.0+

TransactionConfig has a new member called chainVersionString that contains the target chain ID that the transaction is meant for. This value is unset by default. The user may set the value manually if they desire. Semantic versioning is used for the parsing and comparison of the versions. If the value is unset, TransactionProcessor will use the return from getInfo in order to determine the server version and set chainVersionString appropriately. If the value cannot be found or parsed a default of 2.0.0 will be used, causing getBlock to be called for TAPOS rather than getBlockInfo. This should allow the SDK to work transparently on 2.0.0 and 2.1.0+ nodes.

TransactionProcessorTest updated to be parameterized to run one pass with 2.0.0 and another with 2.1.0.

getBlock is used for nodeos chains under 2.1.0 and getBlockInfo
is used for 2.1.0+
Copy link
Contributor

@anguyenqd anguyenqd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments.
I tested these cases and they all were passed:

  • Used the lib with the example app that point to a testnet which were using v2.0.7. Transaction was executed successfully without any configuration.
  • Same set up as above but manually set the chainVersionString to the default value (2.0.0) (Transaction was executed successfully) and the get block Info available value (2.1.0). (Transaction were failed - which is expected)

import one.block.eosiojava.error.rpcProvider.GetInfoRpcError;
import one.block.eosiojava.error.rpcProvider.GetRequiredKeysRpcError;
import one.block.eosiojava.error.rpcProvider.SendTransactionRpcError;
import one.block.eosiojava.error.rpcProvider.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using wildcard import.

@opi-smccoole opi-smccoole requested a review from anguyenqd April 9, 2021 19:50
Copy link

@Ruk1ng001 Ruk1ng001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why I get this URL: http://192.168.182.4:8888/v1/chain/get_block_info
I use SDK 1.0 & eosio version=v1.8.14...
how to resolve this issue?
Thanks.

@opi-smccoole
Copy link
Contributor Author

why I get this URL: http://192.168.182.4:8888/v1/chain/get_block_info
I use SDK 1.0 & eosio version=v1.8.14...
how to resolve this issue?
Thanks.

For now you will have to use the older version of the SDKs until this PR can be merged and a new release deployed. 1.0.0 was originally designed to be released with nodeos 2.1 which replaced get_block in the transaction signing process with get_block_info. 2.1 has been delayed to this PR adds backward compatibility. @GonnaGitYou FYI

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants