Mina中的scan state代码解析

1. 引言

前序博客有:

Mina引入scan state来异步实现交易证明,scan state中有多棵树,将待证明交易作为scan state中树的叶子节点,相应的证明称为base job,树的非叶子节点的证明称为merge job。树的根节点对应的证明称为ledger_proof。

可将scan state中每棵树中的每个节点看成是待完成的job:

  • job状态结构为:Todo和Done 两种状态。
(**Each node on the tree is viewed as a job that needs to be completed. When a job is completed, it creates a new "Todo" job and marks the old job as "Done"*)
module Job_status : sig
  [%%versioned:
  module Stable : sig
    module V1 : sig
      type t = Todo | Done [@@deriving sexp]
  • Weight:可添加到某树的job数,与该树的特定层相关。
(**number of jobs that can be added to this tree. This number corresponding to a specific level of the tree. New jobs received is distributed across the tree based on this number. *)
module Weight : sig
  [%%versioned:
  module Stable : sig
    module V1 : sig
      type t = { base : int; merge : int }
  • Base Job结构为:

2. Mina的Pending coinbase

Mina的pending coinbase本质上是a Merkle tree of “stacks”,每个都包含2个hash值:

  • 第一个哈希值通过push操作,根据coinbase内的元素计算而来;
  • 第二个哈希值为protocol state hash,根据coinbase中的“body” state哈希计算而来。

pending coinbase中还包含一个stack id,用于判定stacks的发生顺序,从而知道哪个是最新的stack,哪个是最老的stack。
此处用stack这个词是不恰当的,其并不遵循last-in-first-out原则,称为“accumulators”累加器更合适。

pending_coinbase结构表示为:

type t = (Merkle_tree.t, Stack_id.t) Poly.t

type ('tree, 'stack_id) t =
      { tree : 'tree; pos_list : 'stack_id list; new_pos : 'stack_id }

附录1. Mina系列博客

Mina系列博客有:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值