_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q32700 | AccountState.Clone | train | def Clone(self):
"""
Clone self.
Returns:
AccountState:
"""
return AccountState(self.ScriptHash, self.IsFrozen, self.Votes, self.Balances) | python | {
"resource": ""
} |
q32701 | AccountState.HasBalance | train | def HasBalance(self, assetId):
"""
Flag indicating if the asset has a balance.
Args:
assetId (UInt256):
Returns:
bool: True if a balance is present. False otherwise.
"""
for key, fixed8 in self.Balances.items():
if key == assetId:
... | python | {
"resource": ""
} |
q32702 | AccountState.BalanceFor | train | def BalanceFor(self, assetId):
"""
Get the balance for a given asset id.
Args:
assetId (UInt256):
Returns:
Fixed8: balance value.
"""
for key, fixed8 in self.Balances.items():
if key == assetId:
return fixed8
r... | python | {
"resource": ""
} |
q32703 | AccountState.AddToBalance | train | def AddToBalance(self, assetId, fixed8_val):
"""
Add amount to the specified balance.
Args:
assetId (UInt256):
fixed8_val (Fixed8): amount to add.
"""
found = False
for key, balance in self.Balances.items():
if key == assetId:
... | python | {
"resource": ""
} |
q32704 | AccountState.SubtractFromBalance | train | def SubtractFromBalance(self, assetId, fixed8_val):
"""
Subtract amount to the specified balance.
Args:
assetId (UInt256):
fixed8_val (Fixed8): amount to add.
"""
found = False
for key, balance in self.Balances.items():
if key == asset... | python | {
"resource": ""
} |
q32705 | AccountState.AllBalancesZeroOrLess | train | def AllBalancesZeroOrLess(self):
"""
Flag indicating if all balances are 0 or less.
Returns:
bool: True if all balances are <= 0. False, otherwise.
"""
for key, fixed8 in self.Balances.items():
if fixed8.value > 0:
return False
ret... | python | {
"resource": ""
} |
q32706 | AccountState.ToByteArray | train | def ToByteArray(self):
"""
Serialize self and get the byte stream.
Returns:
bytes: serialized object.
"""
ms = StreamManager.GetStream()
writer = BinaryWriter(ms)
self.Serialize(writer)
retval = ms.ToArray()
StreamManager.ReleaseStrea... | python | {
"resource": ""
} |
q32707 | NotificationDB.start | train | def start(self):
"""
Handle EventHub events for SmartContract decorators
"""
self._events_to_write = []
self._new_contracts_to_write = []
@events.on(SmartContractEvent.CONTRACT_CREATED)
@events.on(SmartContractEvent.CONTRACT_MIGRATED)
def call_on_success_... | python | {
"resource": ""
} |
q32708 | Header.FromTrimmedData | train | def FromTrimmedData(data, index):
"""
Deserialize into a Header object from the provided data.
Args:
data (bytes):
index: UNUSED
Returns:
Header:
"""
header = Header()
ms = StreamManager.GetStream(data)
reader = Bina... | python | {
"resource": ""
} |
q32709 | ContractParameterType.FromString | train | def FromString(val):
"""
Create a ContractParameterType object from a str
Args:
val (str): the value to be converted to a ContractParameterType.
val can be hex encoded (b'07'), int (7), string int ("7"), or string literal ("String")
Returns:
Contract... | python | {
"resource": ""
} |
q32710 | address_to_scripthash | train | def address_to_scripthash(address: str) -> UInt160:
"""Just a helper method"""
AddressVersion = 23 # fixed at this point
data = b58decode(address)
if len(data) != 25:
raise ValueError('Not correct Address, wrong length.')
if data[0] != AddressVersion:
raise ValueError('Not correct C... | python | {
"resource": ""
} |
q32711 | FunctionCode.HasStorage | train | def HasStorage(self):
"""
Flag indicating if storage is available.
Returns:
bool: True if available. False otherwise.
"""
from neo.Core.State.ContractState import ContractPropertyState
return self.ContractProperties & ContractPropertyState.HasStorage > 0 | python | {
"resource": ""
} |
q32712 | FunctionCode.HasDynamicInvoke | train | def HasDynamicInvoke(self):
"""
Flag indicating if dynamic invocation is supported.
Returns:
bool: True if supported. False otherwise.
"""
from neo.Core.State.ContractState import ContractPropertyState
return self.ContractProperties & ContractPropertyState.Ha... | python | {
"resource": ""
} |
q32713 | FunctionCode.IsPayable | train | def IsPayable(self):
"""
Flag indicating if the contract accepts payments.
Returns:
bool: True if supported. False otherwise.
"""
from neo.Core.State.ContractState import ContractPropertyState
return self.ContractProperties & ContractPropertyState.Payable > 0 | python | {
"resource": ""
} |
q32714 | FunctionCode.ScriptHash | train | def ScriptHash(self):
"""
Get the script hash.
Returns:
UInt160:
"""
if self._scriptHash is None:
self._scriptHash = Crypto.ToScriptHash(self.Script, unhex=False)
return self._scriptHash | python | {
"resource": ""
} |
q32715 | SettingsHolder.setup | train | def setup(self, config_file):
""" Setup settings from a JSON config file """
def get_config_and_warn(key, default, abort=False):
value = config.get(key, None)
if not value:
print(f"Cannot find {key} in settings, using default value: {default}")
va... | python | {
"resource": ""
} |
q32716 | SettingsHolder.setup_privnet | train | def setup_privnet(self, host=None):
"""
Load settings from the privnet JSON config file
Args:
host (string, optional): if supplied, uses this IP or domain as neo nodes. The host must
use these standard ports: P2P 20333, RPC 30333.
"""
... | python | {
"resource": ""
} |
q32717 | SettingsHolder.set_loglevel | train | def set_loglevel(self, level):
"""
Set the minimum loglevel for all components
Args:
level (int): eg. logging.DEBUG or logging.ERROR. See also https://docs.python.org/2/library/logging.html#logging-levels
"""
self.log_level = level
log_manager.config_stdio(de... | python | {
"resource": ""
} |
q32718 | SettingsHolder.check_chain_dir_exists | train | def check_chain_dir_exists(self, warn_migration=False):
"""
Checks to make sure there is a directory called ``Chains`` at the root of DATA_DIR_PATH
and creates it if it doesn't exist yet
"""
chain_path = os.path.join(self.DATA_DIR_PATH, 'Chains')
if not os.path.exists(ch... | python | {
"resource": ""
} |
q32719 | SplitUnspentCoin | train | def SplitUnspentCoin(wallet, asset_id, from_addr, index, divisions, fee=Fixed8.Zero(), prompt_passwd=True):
"""
Split unspent asset vins into several vouts
Args:
wallet (neo.Wallet): wallet to show unspent coins from.
asset_id (UInt256): a bytearray (len 32) representing an asset on the blo... | python | {
"resource": ""
} |
q32720 | load_class_from_path | train | def load_class_from_path(path_and_class: str):
"""
Dynamically load a class from a module at the specified path
Args:
path_and_class: relative path where to find the module and its class name
i.e. 'neo.<package>.<package>.<module>.<class name>'
Raises:
ValueError: if the Module... | python | {
"resource": ""
} |
q32721 | ApplicationEngine.Run | train | def Run(script, container=None, exit_on_error=False, gas=Fixed8.Zero(), test_mode=True):
"""
Runs a script in a test invoke environment
Args:
script (bytes): The script to run
container (neo.Core.TX.Transaction): [optional] the transaction to use as the script container
... | python | {
"resource": ""
} |
q32722 | ConcatenatedEnumerator.Next | train | def Next(self):
"""
Advances the iterator forward 1 step.
Returns:
bool: True if another item exists in the iterator, False otherwise.
"""
try:
self.key, self.value = next(self.current)
except StopIteration:
if self.current != self.... | python | {
"resource": ""
} |
q32723 | AssetType.AllTypes | train | def AllTypes():
"""
Get a list of all available asset types.
Returns:
list: of AssetType items.
"""
return [AssetType.CreditFlag, AssetType.DutyFlag, AssetType.GoverningToken,
AssetType.UtilityToken, AssetType.Currency, AssetType.Share,
... | python | {
"resource": ""
} |
q32724 | custom_background_code | train | def custom_background_code():
""" Custom code run in a background thread. Prints the current block height.
This function is run in a daemonized thread, which means it can be instantly killed at any
moment, whenever the main thread quits. If you need more safety, don't use a daemonized
thread and handl... | python | {
"resource": ""
} |
q32725 | wait_for_tx | train | def wait_for_tx(self, tx, max_seconds=120):
""" Wait for tx to show up on blockchain
Args:
tx (Transaction or UInt256 or str): Transaction or just the hash
max_seconds (float): maximum seconds to wait for tx to show up. default: 120
Returns:
True: if transaction was found
Rais... | python | {
"resource": ""
} |
q32726 | Wallet.AddContract | train | def AddContract(self, contract):
"""
Add a contract to the wallet.
Args:
contract (Contract): a contract of type neo.SmartContract.Contract.
Raises:
Exception: Invalid operation - public key mismatch.
"""
if not contract.PublicKeyHash.ToBytes() i... | python | {
"resource": ""
} |
q32727 | Wallet.AddWatchOnly | train | def AddWatchOnly(self, script_hash):
"""
Add a watch only address to the wallet.
Args:
script_hash (UInt160): a bytearray (len 20) representing the public key.
Note:
Prints a warning to the console if the address already exists in the wallet.
"""
... | python | {
"resource": ""
} |
q32728 | Wallet.AddNEP5Token | train | def AddNEP5Token(self, token):
"""
Add a NEP-5 compliant token to the wallet.
Args:
token (NEP5Token): an instance of type neo.Wallets.NEP5Token.
Note:
Prints a warning to the console if the token already exists in the wallet.
"""
if token.Script... | python | {
"resource": ""
} |
q32729 | Wallet.ChangePassword | train | def ChangePassword(self, password_old, password_new):
"""
Change the password used to protect the private key.
Args:
password_old (str): the current password used to encrypt the private key.
password_new (str): the new to be used password to encrypt the private key.
... | python | {
"resource": ""
} |
q32730 | Wallet.ContainsKey | train | def ContainsKey(self, public_key):
"""
Test if the wallet contains the supplied public key.
Args:
public_key (edcsa.Curve.point): a public key to test for its existance. e.g. KeyPair.PublicKey
Returns:
bool: True if exists, False otherwise.
"""
r... | python | {
"resource": ""
} |
q32731 | Wallet.ContainsAddressStr | train | def ContainsAddressStr(self, address):
"""
Determine if the wallet contains the address.
Args:
address (str): a string representing the public key.
Returns:
bool: True, if the address is present in the wallet. False otherwise.
"""
for key, contra... | python | {
"resource": ""
} |
q32732 | Wallet.CreateKey | train | def CreateKey(self, private_key=None):
"""
Create a KeyPair
Args:
private_key (iterable_of_ints): (optional) 32 byte private key
Returns:
KeyPair: a KeyPair instance
"""
if private_key is None:
private_key = bytes(Random.get_random_by... | python | {
"resource": ""
} |
q32733 | Wallet.EncryptPrivateKey | train | def EncryptPrivateKey(self, decrypted):
"""
Encrypt the provided plaintext with the initialized private key.
Args:
decrypted (byte string): the plaintext to be encrypted.
Returns:
bytes: the ciphertext.
"""
aes = AES.new(self._master_key, AES.MOD... | python | {
"resource": ""
} |
q32734 | Wallet.DecryptPrivateKey | train | def DecryptPrivateKey(self, encrypted_private_key):
"""
Decrypt the provided ciphertext with the initialized private key.
Args:
encrypted_private_key (byte string): the ciphertext to be decrypted.
Returns:
bytes: the ciphertext.
"""
aes = AES.new... | python | {
"resource": ""
} |
q32735 | Wallet.FindCoinsByVins | train | def FindCoinsByVins(self, vins):
"""
Looks through the current collection of coins in a wallet
and chooses coins that match the specified CoinReference objects.
Args:
vins: A list of ``neo.Core.CoinReference`` objects.
Returns:
list: A list of ``neo.Wall... | python | {
"resource": ""
} |
q32736 | Wallet.FindUnspentCoins | train | def FindUnspentCoins(self, from_addr=None, use_standard=False, watch_only_val=0):
"""
Finds unspent coin objects in the wallet.
Args:
from_addr (UInt160): a bytearray (len 20) representing an address.
use_standard (bool): whether or not to only include standard contracts... | python | {
"resource": ""
} |
q32737 | Wallet.FindUnspentCoinsByAsset | train | def FindUnspentCoinsByAsset(self, asset_id, from_addr=None, use_standard=False, watch_only_val=0):
"""
Finds unspent coin objects in the wallet limited to those of a certain asset type.
Args:
asset_id (UInt256): a bytearray (len 32) representing an asset on the blockchain.
... | python | {
"resource": ""
} |
q32738 | Wallet.FindUnspentCoinsByAssetAndTotal | train | def FindUnspentCoinsByAssetAndTotal(self, asset_id, amount, from_addr=None, use_standard=False, watch_only_val=0, reverse=False):
"""
Finds unspent coin objects totalling a requested value in the wallet limited to those of a certain asset type.
Args:
asset_id (UInt256): a bytearray ... | python | {
"resource": ""
} |
q32739 | Wallet.GetUnclaimedCoins | train | def GetUnclaimedCoins(self):
"""
Gets coins in the wallet that have not been 'claimed', or redeemed for their gas value on the blockchain.
Returns:
list: a list of ``neo.Wallet.Coin`` that have 'claimable' value
"""
unclaimed = []
neo = Blockchain.SystemShar... | python | {
"resource": ""
} |
q32740 | Wallet.GetAvailableClaimTotal | train | def GetAvailableClaimTotal(self):
"""
Gets the total amount of Gas that this wallet is able to claim at a given moment.
Returns:
Fixed8: the amount of Gas available to claim as a Fixed8 number.
"""
coinrefs = [coin.Reference for coin in self.GetUnclaimedCoins()]
... | python | {
"resource": ""
} |
q32741 | Wallet.GetUnavailableBonus | train | def GetUnavailableBonus(self):
"""
Gets the total claimable amount of Gas in the wallet that is not available to claim
because it has not yet been spent.
Returns:
Fixed8: the amount of Gas unavailable to claim.
"""
height = Blockchain.Default().Height + 1
... | python | {
"resource": ""
} |
q32742 | Wallet.GetKey | train | def GetKey(self, public_key_hash):
"""
Get the KeyPair belonging to the public key hash.
Args:
public_key_hash (UInt160): a public key hash to get the KeyPair for.
Returns:
KeyPair: If successful, the KeyPair belonging to the public key hash, otherwise None
... | python | {
"resource": ""
} |
q32743 | Wallet.GetKeyByScriptHash | train | def GetKeyByScriptHash(self, script_hash):
"""
Get the KeyPair belonging to the script hash.
Args:
script_hash (UInt160): a bytearray (len 20) representing the public key.
Returns:
KeyPair: If successful, the KeyPair belonging to the public key hash, otherwise N... | python | {
"resource": ""
} |
q32744 | Wallet.GetTokenBalance | train | def GetTokenBalance(self, token, watch_only=0):
"""
Get the balance of the specified token.
Args:
token (NEP5Token): an instance of type neo.Wallets.NEP5Token to get the balance from.
watch_only (bool): True, to limit to watch only wallets.
Returns:
... | python | {
"resource": ""
} |
q32745 | Wallet.GetBalance | train | def GetBalance(self, asset_id, watch_only=0):
"""
Get the balance of a specific token by its asset id.
Args:
asset_id (NEP5Token|TransactionOutput): an instance of type neo.Wallets.NEP5Token or neo.Core.TX.Transaction.TransactionOutput to get the balance from.
watch_only... | python | {
"resource": ""
} |
q32746 | Wallet.ProcessBlocks | train | def ProcessBlocks(self, block_limit=1000):
"""
Method called on a loop to check the current height of the blockchain. If the height of the blockchain
is more than the current stored height in the wallet, we get the next block in line and
processes it.
In the case that the walle... | python | {
"resource": ""
} |
q32747 | Wallet.ProcessNewBlock | train | def ProcessNewBlock(self, block):
"""
Processes a block on the blockchain. This should be done in a sequential order, ie block 4 should be
only processed after block 3.
Args:
block: (neo.Core.Block) a block on the blockchain.
"""
added = set()
change... | python | {
"resource": ""
} |
q32748 | Wallet.IsWalletTransaction | train | def IsWalletTransaction(self, tx):
"""
Verifies if a transaction belongs to the wallet.
Args:
tx (TransactionOutput):an instance of type neo.Core.TX.Transaction.TransactionOutput to verify.
Returns:
bool: True, if transaction belongs to wallet. False, if not.
... | python | {
"resource": ""
} |
q32749 | Wallet.CheckAddressState | train | def CheckAddressState(self, script_hash):
"""
Determine the address state of the provided script hash.
Args:
script_hash (UInt160): a script hash to determine the address state of.
Returns:
AddressState: the address state.
"""
for key, contract i... | python | {
"resource": ""
} |
q32750 | Wallet.ToScriptHash | train | def ToScriptHash(self, address):
"""
Retrieve the script_hash based from an address.
Args:
address (str): a base58 encoded address.
Raises:
ValuesError: if an invalid address is supplied or the coin version is incorrect
Exception: if the address stri... | python | {
"resource": ""
} |
q32751 | Wallet.ValidatePassword | train | def ValidatePassword(self, password):
"""
Validates if the provided password matches with the stored password.
Args:
password (string): a password.
Returns:
bool: the provided password matches with the stored password.
"""
password = to_aes_key(p... | python | {
"resource": ""
} |
q32752 | Wallet.GetStandardAddress | train | def GetStandardAddress(self):
"""
Get the Wallet's default address.
Raises:
Exception: if no default contract address is set.
Returns:
UInt160: script hash.
"""
for contract in self._contracts.values():
if contract.IsStandard:
... | python | {
"resource": ""
} |
q32753 | Wallet.GetChangeAddress | train | def GetChangeAddress(self, from_addr=None):
"""
Get the address where change is send to.
Args:
from_address (UInt160): (optional) from address script hash.
Raises:
Exception: if change address could not be found.
Returns:
UInt160: script has... | python | {
"resource": ""
} |
q32754 | Wallet.GetDefaultContract | train | def GetDefaultContract(self):
"""
Get the default contract.
Returns:
contract (Contract): if Successful, a contract of type neo.SmartContract.Contract, otherwise an Exception.
Raises:
Exception: if no default contract is found.
Note:
Prints ... | python | {
"resource": ""
} |
q32755 | Wallet.GetCoinAssets | train | def GetCoinAssets(self):
"""
Get asset ids of all coins present in the wallet.
Returns:
list: of UInt256 asset id's.
"""
assets = set()
for coin in self.GetCoins():
assets.add(coin.Output.AssetId)
return list(assets) | python | {
"resource": ""
} |
q32756 | Wallet.GetContract | train | def GetContract(self, script_hash):
"""
Get contract for specified script_hash.
Args:
script_hash (UInt160): a bytearray (len 20).
Returns:
Contract: if a contract was found matching the provided script hash, otherwise None
"""
if script_hash.ToB... | python | {
"resource": ""
} |
q32757 | Wallet.SaveTransaction | train | def SaveTransaction(self, tx):
"""
This method is used to after a transaction has been made by this wallet. It updates the states of the coins
In the wallet to reflect the new balance, but the coins remain in a ``CoinState.UNCONFIRMED`` state until
The transaction has been processed by ... | python | {
"resource": ""
} |
q32758 | Wallet.SignMessage | train | def SignMessage(self, message, script_hash):
"""
Sign a message with a specified script_hash.
Args:
message (str): a hex encoded message to sign
script_hash (UInt160): a bytearray (len 20).
Returns:
str: the signed message
"""
keypai... | python | {
"resource": ""
} |
q32759 | Wallet.IsSynced | train | def IsSynced(self):
"""
Check if wallet is synced.
Returns:
bool: True if wallet is synced.
"""
if Blockchain.Default().Height == 0:
return False
if (int(100 * self._current_height / Blockchain.Default().Height)) < 100:
return False
... | python | {
"resource": ""
} |
q32760 | UserWallet.Create | train | def Create(path, password, generate_default_key=True):
"""
Create a new user wallet.
Args:
path (str): A path indicating where to create or open the wallet e.g. "/Wallets/mywallet".
password (str): a 10 characters minimum password to secure the wallet with.
Retu... | python | {
"resource": ""
} |
q32761 | UserWallet.CreateKey | train | def CreateKey(self, prikey=None):
"""
Create a KeyPair and store it encrypted in the database.
Args:
private_key (iterable_of_ints): (optional) 32 byte private key.
Returns:
KeyPair: a KeyPair instance.
"""
account = super(UserWallet, self).Creat... | python | {
"resource": ""
} |
q32762 | UserWallet.OnCreateAccount | train | def OnCreateAccount(self, account):
"""
Save a KeyPair in encrypted form into the database.
Args:
account (KeyPair):
"""
pubkey = account.PublicKey.encode_point(False)
pubkeyunhex = binascii.unhexlify(pubkey)
pub = pubkeyunhex[1:65]
priv = by... | python | {
"resource": ""
} |
q32763 | UserWallet.AddContract | train | def AddContract(self, contract):
"""
Add a contract to the database.
Args:
contract(neo.SmartContract.Contract): a Contract instance.
"""
super(UserWallet, self).AddContract(contract)
try:
db_contract = Contract.get(ScriptHash=contract.ScriptHash... | python | {
"resource": ""
} |
q32764 | NeoNode.Disconnect | train | def Disconnect(self, reason=None, isDead=True):
"""Close the connection with the remote node client."""
self.disconnecting = True
self.expect_verack_next = False
if reason:
logger.debug(f"Disconnecting with reason: {reason}")
self.stop_block_loop()
self.stop_h... | python | {
"resource": ""
} |
q32765 | NeoNode.Name | train | def Name(self):
"""
Get the peer name.
Returns:
str:
"""
name = ""
if self.Version:
name = self.Version.UserAgent
return name | python | {
"resource": ""
} |
q32766 | NeoNode.GetNetworkAddressWithTime | train | def GetNetworkAddressWithTime(self):
"""
Get a network address object.
Returns:
NetworkAddressWithTime: if we have a connection to a node.
None: otherwise.
"""
if self.port is not None and self.host is not None and self.Version is not None:
re... | python | {
"resource": ""
} |
q32767 | NeoNode.connectionMade | train | def connectionMade(self):
"""Callback handler from twisted when establishing a new connection."""
self.endpoint = self.transport.getPeer()
# get the reference to the Address object in NodeLeader so we can manipulate it properly.
tmp_addr = Address(f"{self.endpoint.host}:{self.endpoint.po... | python | {
"resource": ""
} |
q32768 | NeoNode.connectionLost | train | def connectionLost(self, reason=None):
"""Callback handler from twisted when a connection was lost."""
try:
self.connected = False
self.stop_block_loop()
self.stop_peerinfo_loop()
self.stop_header_loop()
self.ReleaseBlockRequests()
... | python | {
"resource": ""
} |
q32769 | NeoNode.dataReceived | train | def dataReceived(self, data):
""" Called from Twisted whenever data is received. """
self.bytes_in += (len(data))
self.buffer_in = self.buffer_in + data
while self.CheckDataReceived():
pass | python | {
"resource": ""
} |
q32770 | NeoNode.CheckDataReceived | train | def CheckDataReceived(self):
"""Tries to extract a Message from the data buffer and process it."""
currentLength = len(self.buffer_in)
if currentLength < 24:
return False
# Extract the message header from the buffer, and return if not enough
# buffer to fully deserial... | python | {
"resource": ""
} |
q32771 | NeoNode.HandlePeerInfoReceived | train | def HandlePeerInfoReceived(self, payload):
"""Process response of `self.RequestPeerInfo`."""
addrs = IOHelper.AsSerializableWithType(payload, 'neo.Network.Payloads.AddrPayload.AddrPayload')
if not addrs:
return
for nawt in addrs.NetworkAddressesWithTime:
self.le... | python | {
"resource": ""
} |
q32772 | NeoNode.SendVersion | train | def SendVersion(self):
"""Send our client version."""
m = Message("version", VersionPayload(settings.NODE_PORT, self.remote_nodeid, settings.VERSION_NAME))
self.SendSerializedMessage(m) | python | {
"resource": ""
} |
q32773 | NeoNode.SendVerack | train | def SendVerack(self):
"""Send version acknowledge"""
m = Message('verack')
self.SendSerializedMessage(m)
self.expect_verack_next = True | python | {
"resource": ""
} |
q32774 | NeoNode.HandleVersion | train | def HandleVersion(self, payload):
"""Process the response of `self.RequestVersion`."""
self.Version = IOHelper.AsSerializableWithType(payload, "neo.Network.Payloads.VersionPayload.VersionPayload")
if not self.Version:
return
if self.incoming_client:
if self.Vers... | python | {
"resource": ""
} |
q32775 | NeoNode.HandleVerack | train | def HandleVerack(self):
"""Handle the `verack` response."""
m = Message('verack')
self.SendSerializedMessage(m)
self.leader.NodeCount += 1
self.identifier = self.leader.NodeCount
logger.debug(f"{self.prefix} Handshake complete!")
self.handshake_complete = True
... | python | {
"resource": ""
} |
q32776 | NeoNode.SendSerializedMessage | train | def SendSerializedMessage(self, message):
"""
Send the `message` to the remote client.
Args:
message (neo.Network.Message):
"""
try:
ba = Helper.ToArray(message)
ba2 = binascii.unhexlify(ba)
self.bytes_out += len(ba2)
s... | python | {
"resource": ""
} |
q32777 | NeoNode.HandleBlockReceived | train | def HandleBlockReceived(self, inventory):
"""
Process a Block inventory payload.
Args:
inventory (neo.Network.Inventory):
"""
block = IOHelper.AsSerializableWithType(inventory, 'neo.Core.Block.Block')
if not block:
return
blockhash = bloc... | python | {
"resource": ""
} |
q32778 | NeoNode.HandleGetDataMessageReceived | train | def HandleGetDataMessageReceived(self, payload):
"""
Process a InvPayload payload.
Args:
payload (neo.Network.Inventory):
"""
inventory = IOHelper.AsSerializableWithType(payload, 'neo.Network.Payloads.InvPayload.InvPayload')
if not inventory:
retu... | python | {
"resource": ""
} |
q32779 | NeoNode.HandleGetBlocksMessageReceived | train | def HandleGetBlocksMessageReceived(self, payload):
"""
Process a GetBlocksPayload payload.
Args:
payload (neo.Network.Payloads.GetBlocksPayload):
"""
if not self.leader.ServiceEnabled:
return
inventory = IOHelper.AsSerializableWithType(payload, '... | python | {
"resource": ""
} |
q32780 | NeoNode.Relay | train | def Relay(self, inventory):
"""
Wrap the inventory in a InvPayload object and send it over the write to the remote node.
Args:
inventory:
Returns:
bool: True (fixed)
"""
inventory = InvPayload(type=inventory.InventoryType, hashes=[inventory.Hash.... | python | {
"resource": ""
} |
q32781 | Helper.DeserializeTX | train | def DeserializeTX(buffer):
"""
Deserialize the stream into a Transaction object.
Args:
buffer (BytesIO): stream to deserialize the Transaction from.
Returns:
neo.Core.TX.Transaction:
"""
mstream = MemoryStream(buffer)
reader = BinaryReade... | python | {
"resource": ""
} |
q32782 | UnspentCoinState.FromTXOutputsConfirmed | train | def FromTXOutputsConfirmed(outputs):
"""
Get unspent outputs from a list of transaction outputs.
Args:
outputs (list): of neo.Core.TX.Transaction.TransactionOutput items.
Returns:
UnspentCoinState:
"""
uns = UnspentCoinState()
uns.Items =... | python | {
"resource": ""
} |
q32783 | UnspentCoinState.IsAllSpent | train | def IsAllSpent(self):
"""
Flag indicating if all balance is spend.
Returns:
bool:
"""
for item in self.Items:
if item == CoinState.Confirmed:
return False
return True | python | {
"resource": ""
} |
q32784 | Transaction.Hash | train | def Hash(self):
"""
Get the hash of the transaction.
Returns:
UInt256:
"""
if not self.__hash:
ba = bytearray(binascii.unhexlify(self.GetHashData()))
hash = Crypto.Hash256(ba)
self.__hash = UInt256(data=hash)
return self.__... | python | {
"resource": ""
} |
q32785 | Transaction.References | train | def References(self):
"""
Get all references.
Returns:
dict:
Key (UInt256): input PrevHash
Value (TransactionOutput): object.
"""
if self.__references is None:
refs = {}
# group by the input prevhash
... | python | {
"resource": ""
} |
q32786 | Transaction.NetworkFee | train | def NetworkFee(self):
"""
Get the network fee.
Returns:
Fixed8:
"""
if self._network_fee is None:
input = Fixed8(0)
for coin_ref in self.References.values():
if coin_ref.AssetId == GetBlockchain().SystemCoin().Hash:
... | python | {
"resource": ""
} |
q32787 | Transaction.DeserializeFromBufer | train | def DeserializeFromBufer(buffer, offset=0):
"""
Deserialize object instance from the specified buffer.
Args:
buffer (bytes, bytearray, BytesIO): (Optional) data to create the stream from.
offset: UNUSED
Returns:
Transaction:
"""
mstre... | python | {
"resource": ""
} |
q32788 | Transaction.DeserializeUnsigned | train | def DeserializeUnsigned(self, reader):
"""
Deserialize object.
Args:
reader (neo.IO.BinaryReader):
Raises:
Exception: if transaction type is incorrect.
"""
txtype = reader.ReadByte()
if txtype != int.from_bytes(self.Type, 'little'):
... | python | {
"resource": ""
} |
q32789 | Transaction.DeserializeUnsignedWithoutType | train | def DeserializeUnsignedWithoutType(self, reader):
"""
Deserialize object without reading transaction type data.
Args:
reader (neo.IO.BinaryReader):
"""
self.Version = reader.ReadByte()
self.DeserializeExclusiveData(reader)
self.Attributes = reader.Rea... | python | {
"resource": ""
} |
q32790 | Transaction.GetTransactionResults | train | def GetTransactionResults(self):
"""
Get the execution results of the transaction.
Returns:
None: if the transaction has no references.
list: of TransactionResult objects.
"""
if self.References is None:
return None
results = []
... | python | {
"resource": ""
} |
q32791 | ContractParameter.ToParameter | train | def ToParameter(item: StackItem):
"""
Convert a StackItem to a ContractParameter object
Args:
item (neo.VM.InteropService.StackItem) The item to convert to a ContractParameter object
Returns:
ContractParameter
"""
if isinstance(item, Array) or i... | python | {
"resource": ""
} |
q32792 | ContractParameter.ToJson | train | def ToJson(self, auto_hex=True):
"""
Converts a ContractParameter instance to a json representation
Returns:
dict: a dictionary representation of the contract parameter
"""
jsn = {}
jsn['type'] = str(ContractParameterType(self.Type))
if self.Type == ... | python | {
"resource": ""
} |
q32793 | ContractParameter.ToVM | train | def ToVM(self):
"""
Used for turning a ContractParameter item into somethnig consumable by the VM
Returns:
"""
if self.Type == ContractParameterType.String:
return str(self.Value).encode('utf-8').hex()
elif self.Type == ContractParameterType.Integer and isin... | python | {
"resource": ""
} |
q32794 | ContractParameter.FromJson | train | def FromJson(json):
"""
Convert a json object to a ContractParameter object
Args:
item (dict): The item to convert to a ContractParameter object
Returns:
ContractParameter
"""
type = ContractParameterType.FromString(json['type'])
value ... | python | {
"resource": ""
} |
q32795 | Coin.CoinFromRef | train | def CoinFromRef(coin_ref, tx_output, state=CoinState.Unconfirmed, transaction=None):
"""
Get a Coin object using a CoinReference.
Args:
coin_ref (neo.Core.CoinReference): an object representing a single UTXO / transaction input.
tx_output (neo.Core.Transaction.Transactio... | python | {
"resource": ""
} |
q32796 | CoinReference.Equals | train | def Equals(self, other):
"""
Test for equality.
Args:
other (obj):
Returns:
bool: True `other` equals self.
"""
if other is None:
return False
if other.PrevHash.ToBytes() == self.PrevHash.ToBytes() and other.PrevIndex == self.... | python | {
"resource": ""
} |
q32797 | Helper.GetHashData | train | def GetHashData(hashable):
"""
Get the data used for hashing.
Args:
hashable (neo.IO.Mixins.SerializableMixin): object extending SerializableMixin
Returns:
bytes:
"""
ms = StreamManager.GetStream()
writer = BinaryWriter(ms)
hashab... | python | {
"resource": ""
} |
q32798 | Helper.Sign | train | def Sign(verifiable, keypair):
"""
Sign the `verifiable` object with the private key from `keypair`.
Args:
verifiable:
keypair (neocore.KeyPair):
Returns:
bool: True if successfully signed. False otherwise.
"""
prikey = bytes(keypair.... | python | {
"resource": ""
} |
q32799 | Helper.AddrStrToScriptHash | train | def AddrStrToScriptHash(address):
"""
Convert a public address to a script hash.
Args:
address (str): base 58 check encoded public address.
Raises:
ValueError: if the address length of address version is incorrect.
Exception: if the address checksum ... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.