Rholang以及Rho演算的逻辑

XiLaiTL小于 1 分钟

Rholang以及Rho演算的逻辑

bnf:

M,N ::= 0 // nil or stopped process
| for( x1 <- y1; … ; xN <- yN ) P // input guarded agent
| x!( P ) // output
| M + N // summation or choice

P,Q ::= M // "normal" process
| *x // dereferenced or unquoted name
| P | Q // parallel composition

x, y ::= @P // name or quoted process

一切皆Process以及两种Process

  1. 所有字面量都是Process。
  2. Process之间通过消息进行通信

QuotedProcess

也就是name、channel

new quotedProcess in {
	quotedProcess!("HelloWorld")
}

Process

所有字面量(字符串等等)

new quotedProcess in {
    for( quotedProcessChild<- quotedProcess){
        quotedProcess!(process)
    }
}

两者转换

@process -> quotedProcess
process <- *quotedProcess

消息传递

从quotedProcess中取出消息:

contract quotedProcess(quotedProcessChild) = {

}
//quotedProcess每次接收到消息就完成{}
for(quotedProcessChild < = quotedProcess ){

}
//quotedProcess每次接收到消息就完成{}


for(quotedProcessChild<-quotedProcess ){

}
//quotedProcess接收了一次消息就完成{}

向quotedProcess中发送消息:

quotedProcess!(process)

Rholang代码执行的本质是channel中的状态变化,也就是说元组空间的状态变迁

持久化消息传递,不会被消费的消息:

quotedProcess!!(process)

数据类型

数字

bool

String

条件

  • if ( BExp ) Proc
  • if ( BExp ) Proc else Proc

Bundle

管理数据的读写权限

模式匹配

pattern

match

match Process {
  Pattern1 => { Process1 }
  ...
  PatternN => { ProcessN }
  _        => { Nil      }
}

数据结构

List

Map

Set

上次编辑于:
贡献者: XiLaiTL