Skip to content

Instantly share code, notes, and snippets.

View davidawad's full-sized avatar
🇪🇬
البحث عن الحقيقة

David Awad davidawad

🇪🇬
البحث عن الحقيقة
View GitHub Profile
class CarIssueFlow {
@InitiatingFlow
@StartableByRPC
class Initiator(var owningBank: Party, var holdingDealer: Party) : FlowLogic<SignedTransaction?>() {
@Suspendable
@Throws(FlowException::class)
override fun call(): SignedTransaction {
// find a notary for the transaction
val notary = serviceHub.networkMapCache.notaryIdentities[0]
// get a reference to the manufacturer node, the only node that can issue new cars
class CarContract : Contract {
@Throws(IllegalArgumentException::class)
override fun verify(tx: LedgerTransaction) {
val (signers, _, value) = tx.commands.requireSingleCommand(Commands::class.java)
val inputs = tx.inputStates
val outputs = tx.outputStates
if (value is Commands.Issue) {
requireThat {
"Transaction must have no input states.".using(inputs.isEmpty())
"Transaction must have exactly one output.".using(outputs.size == 1)
@BelongsToContract(CarContract::class)
class CarState(private val owningBank: Party,
private val holdingDealer: Party,
private val manufacturer: Party,
private val vin: String,
private val licensePlateNumber: String,
private val make: String,
private val model: String,
private val dealershipLocation: String) : ContractState {
// Example Creating an account by using sub-flow (from inside a flow).
val accountInfo: StateAndRef<AccountInfo> = subFlow(CreateAccount("David's account"))
@davidawad
davidawad / node.gradle
Last active March 5, 2021 17:14
example node configuration
node {
name "O=PartyA,L=London,C=GB"
p2pPort 10006
rpcSettings {
address("localhost:10016")
adminAddress("localhost:10046")
}
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
}
@davidawad
davidawad / Dockerfile
Created February 24, 2021 19:09
Example Docker file: From Bank in a Box
FROM corda/corda-zulu-java1.8-4.6
# from https://github.com/corda/bank-in-a-box/blob/release/bankinabox/1.0/docker/corda-node/Dockerfile
USER "root"
## Add packages, clean cache, create dirs, create corda user and change ownership
RUN apt-get update && \
apt-get install -y wget
## PostgreSQL JDBC

Bank in a Box Workshop for Capital Markets : Speaker Notes

Installing and Configuring a local Kubernetes cluster

brew install docker kubectl helm 

You can do this with docker for mac by enabling kubernetes
Make sure to set docker for mac's resources for this demo. Ideally 8GB CPU, and 12GB of Memory.

@davidawad
davidawad / service-account.yaml
Last active February 11, 2021 19:57
simple kubernetes admin user config
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
@davidawad
davidawad / example.java
Created February 9, 2021 19:13
example usage of custom logging in corda
Logger logger = LoggerFactory.getLogger("net.corda"); // note this logger's name is specified in the xml config
Party me = getOurIdentity();
// we have an opportunity to log out the contents of the flow arguments.
ThreadContext.put("initiator", me.getName().toString());
ThreadContext.put("target", target.getName().toString());
// publish to the log with the additional context
logger.info("Initializing the transaction.");
// flush the threadContext of these additional properties
ThreadContext.removeAll(Arrays.asList("initiator", "target"));
@davidawad
davidawad / json.xml
Created February 9, 2021 19:04
log4j configuration file for json logging
<?xml version="1.0" encoding="UTF-8"?>
<!--
Be aware that this is a configuration file for Apache log4j,
This example file will log json files but there are many other configurations
You can also use files such as ../sql.xml as well.
-->
<Configuration status="info">
<Appenders>
<Console name="ConsoleJSONAppender" target="SYSTEM_OUT">