Struct emulator_connect::connections::hd::HDOracleEmulatorConnection [−][src]
pub struct HDOracleEmulatorConnection {
pub runtime: Arc<Runtime>,
pub connection: Mutex<Option<TcpStream>>,
pub reconnect: SocketAddr,
pub root: ExtendedPubKey,
pub secp: Arc<Secp256k1<All>>,
}
Expand description
HDOracleEmulatorConnection wraps a tokio runtime and a TCPStream with a key to be able to talk to an Oracle server.
Note that because HDOracleEmulatorConnection uses block_in_place/block_on internally in the trait object because the CTVEmulator trait is not async.
This seems to be a limitation with tokio / rust around using async inside non-async traits.
Fields
runtime: Arc<Runtime>
connection: Mutex<Option<TcpStream>>
reconnect: SocketAddr
root: ExtendedPubKey
secp: Arc<Secp256k1<All>>
Implementations
Creates a new instance of a HDOracleEmulatorConnection.
Note that the runtime and secp can be shared with other instances as it is Arc.
new
does not connect to the address passed in immediately, but it does
use tokio::net::lookup_host to resolve the address. A connection is not
opened to the server until a call to the sign
method is made. This is
purposeful so that connections are not opened until they are actually needed.
Note that as a consequence of new doing the host resolving, if DNS records change, then a new HDOracleEmulatorConnection would need to be created to observe it.
Trait Implementations
For a given transaction hash, gets the corresponding Clause that the Emulator would satisfy. Read more
fn sign(
&self,
b: PartiallySignedTransaction
) -> Result<PartiallySignedTransaction, EmulatorError>
fn sign(
&self,
b: PartiallySignedTransaction
) -> Result<PartiallySignedTransaction, EmulatorError>
Adds the Emulators signature to the PSBT, if any.