Skip to content

Instantly share code, notes, and snippets.

View amolpednekar's full-sized avatar
🍕
Will code for pizza!

Amol Pednekar amolpednekar

🍕
Will code for pizza!
View GitHub Profile
// Authorise the upgrade of all the State instances using OldContract.
listOf(partyAProxy, partyBProxy).forEach { proxy ->
// Extract all the unconsumed State instances from the vault.
val stateAndRefs = proxy.vaultQuery(OldState::class.java).states
// Run the upgrade flow for each one.
stateAndRefs
.filter { stateAndRef ->
stateAndRef.state.contract.equals(OldContract.id)
}.forEach { stateAndRef ->
proxy.startFlowDynamic(
// Create a connection to PartyA and PartyB.
val (partyAProxy, partyBProxy) = args.map { arg ->
val nodeAddress = parse(arg)
val client = CordaRPCClient(nodeAddress)
client.start("user1", "test").proxy
}
// Issue a State that uses OldContract onto the ledger.
val partyBIdentity = partyBProxy.nodeInfo().legalIdentities.first()
partyAProxy.startFlowDynamic(Initiator::class.java, partyBIdentity)
Thread.sleep(5000)
// Upgraded contracts must implement the UpgradedContract interface.
// We're also upgrading the state, so we pass the references to the old and new state as the input and output state.
open class NewContractAndState : UpgradedContract<OldState, NewContractAndState.NewState> {
companion object {
val id = "com.upgrade.NewContractAndState"
}
// We're upgrading the state as well, so we modify the OldState.
override fun upgrade(state: OldState) = NewContractAndState.NewState(state.a, state.b, 1)
data class OldState(val a: AbstractParty, val b: AbstractParty) : ContractState {
override val participants get() = listOf(a, b)
}
open class OldContract : Contract {
companion object {
val id = "com.upgrade.OldContract"
}
override fun verify(tx: LedgerTransaction) {}
<?php
ini_set('max_execution_time', 0);
$host="10.xxx.x.xx";
$port="999";
$user="username";
$password="password";
$url='http://'.$host.':'.$port.'/';
$strUserPass64= base64_encode($user.':'.$password);
$method="publish";
$params=array("mystream","key9991","AB");
"use strict";
const http = require("http");
const https = require("https");
let client = (connection) => {
let options = {
host: connection.host,
port: connection.port,
method: "POST",
@amolpednekar
amolpednekar / planets.js
Created December 1, 2017 15:41
Vacation labs angular-workshop entry code
/* Write a program in JS that prints numbers 1 to 100. For every multiple of 3, print "Earth".
For every multiple of 5, print "Jupiter". For every multiple of 9, print "Pluto".
Create a Github repo, and save this JS file in it. Paste the URL of the repo here. */
for (let i = 1; i <= 100; i++) {
let output = "";
if (i % 3 === 0) {
output += "Earth "
}
@amolpednekar
amolpednekar / Rinkeby Primary Account
Created May 2, 2017 04:56
Rinkeby Primary Account file for faucet
0x042a7224a7f296226ad8069938ffe3d2be574720