我正在尝试创建一个由买方,卖方,提供商,托运人等组成的示例BlockChain应用程序。作为买方,我成功地创建了一个购买交易,并且还将交易从创建更新为购买。现在,一旦订单处于购买状态,卖方可以更改订单以指示提供商填写订单。由于某些原因,卖方无法这样做。我将模型和ACL以及异常堆栈跟踪附加到有人看这个并且确切地说我正在做的是正确还是错误。如果您发现任何错误,请咨询正确的方法。 TIA。
Permissions.acl
rule NetworkAdminUser {
description: "Grant business network administrators full access to user resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "**"
action: ALLOW
}
rule NetworkAdminSystem {
description: "Grant business network administrators full access to system resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
/**
* end of V0.14 additions
*/
/**
*
**/
rule BuyerACLCreate {
description: "Enable Buyers to execute all actions on an Order"
participant(m): "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.CreateOrder"
condition: (v.buyer.buyerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule BuyerACLBuy {
description: "Enable a Buyer to update an Order from Create to Buy"
participant(m): "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.Buy"
condition: (v.buyer.buyerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule BuyerACLCancel {
description: "Enable a Buyer to CANCEL an Order"
participant(m): "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE, DELETE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.OrderCancel"
condition: (v.buyer.buyerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule BuyerACLDispute {
description: "Enable a Buyer to raise a DISPUTE on an Order"
participant(m): "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.Dispute"
condition: (v.buyer.buyerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule BuyerACLResolve {
description: "Enable a Buyer to RESOLVE a DISPUTEd Order"
participant(m): "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.Resolve"
condition: (v.buyer.buyerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule BuyerACLAuthorizePayment {
description: "Enable a Buyer to AuthorizePayment for an Order"
participant(m): "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.AuthorizePayment"
condition: (v.buyer.buyerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule BuyerACL {
description: "Allow Buyer full access to any order where they are listed as Buyer"
participant(m): "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE, DELETE
resource(v): "org.acme.Z2BTestNetwork.Order"
condition: (v.buyer.buyerID == m.getIdentifier())
action: ALLOW
}
/**
*
*/
rule netAccessBuyer {
description: "Allow Buyers access to the network"
participant: "org.acme.Z2BTestNetwork.Buyer"
operation: READ, CREATE, UPDATE, DELETE
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
/**
*
**/
rule SellerOrderFromSupplier {
description: "Enable a Seller to Submit an Order to a third party for fulfillment"
participant(m): "org.acme.Z2BTestNetwork.Seller"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.OrderFromSupplier"
condition: (v.seller.sellerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule SellerRequestPayment {
description: "Enable a Seller to request payment for a fulfilled order"
participant(m): "org.acme.Z2BTestNetwork.Seller"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.RequestPayment"
condition: (v.seller.sellerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule SellerResolve {
description: "Enable a Seller to resolve a dispute"
participant(m): "org.acme.Z2BTestNetwork.Seller"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.Resolve"
condition: (v.seller.sellerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule SellerRefund {
description: "Enable a Seller to refund payment for a disputed order"
participant(m): "org.acme.Z2BTestNetwork.Seller"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.**"
transaction(tx): "org.acme.Z2BTestNetwork.Refund"
condition: (v.seller.sellerID == m.getIdentifier())
action: ALLOW
}
/**
*
**/
rule SellerACL {
description: "Allow Seller full access to order where they are listed as seller and the order has been Submitted for Purchase"
participant(m): "org.acme.Z2BTestNetwork.Seller"
operation: READ, CREATE, UPDATE
resource(v): "org.acme.Z2BTestNetwork.Order"
condition: ((v.seller.sellerID == m.getIdentifier()) && (v.bought != ''))
action: ALLOW
}
/**
*
*/
rule netAccessSeller {
description: "Allow Sellers access to the network"
participant: "org.acme.Z2BTestNetwork.Seller"
operation: READ, CREATE, UPDATE, DELETE
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
/**
*
**/
rule FinanceCoACL {
description: "Allow FinanceCo full access to all Orders"
participant: "org.acme.Z2BTestNetwork.FinanceCo"
operation: ALL
resource: "org.acme.Z2BTestNetwork.*"
action: ALLOW
}
模型
namespace org.acme.Z2BTestNetwork
import composer.base.*
import composer.events.*
participant Buyer identified by buyerID extends Member{
o String buyerID
}
participant Seller identified by sellerID extends Member{
o String sellerID
}
participant Shipper identified by shipperID extends Member {
o String shipperID
}
participant Provider identified by providerID extends Member {
o String providerID
}
participant FinanceCo identified by financeCoID extends Member {
o String financeCoID
}
asset Order identified by orderNumber {
o String orderNumber
o String[] items
o String status
o String dispute
o String resolve
o String backorder
o String refund
o Integer amount
o String created
o String bought
o String cancelled
o String ordered
o String dateBackordered
o String requestShipment
o String delivered
o String delivering
o String disputeOpened
o String disputeResolved
o String paymentRequested
o String orderRefunded
o String approved
o String paid
--> Provider provider
--> Shipper shipper
--> Buyer buyer
--> Seller seller
--> FinanceCo financeCo
}
transaction CreateOrder {
o Integer amount
--> Order order
--> Buyer buyer
--> Seller seller
--> FinanceCo financeCo
}
transaction OrderCancel {
--> Order order
--> Buyer buyer
--> Seller seller
}
transaction Buy {
--> Order order
--> Buyer buyer
--> Seller seller
}
transaction OrderFromSupplier {
--> Order order
--> Provider provider
--> Seller seller
}
transaction RequestShipping {
--> Order order
--> Shipper shipper
--> Provider provider
}
transaction Deliver {
--> Order order
--> Shipper shipper
}
transaction Delivering {
o String deliveryStatus
--> Order order
--> Shipper shipper
}
transaction BackOrder {
o String backorder
--> Order order
--> Provider provider
}
transaction Dispute {
o String dispute
--> Order order
--> Buyer buyer
--> Seller seller
--> FinanceCo financeCo
}
transaction Resolve {
o String resolve
--> Order order
--> Buyer buyer
--> Seller seller
--> Shipper shipper
--> Provider provider
--> FinanceCo financeCo
}
transaction RequestPayment {
--> Order order
--> Seller seller
--> FinanceCo financeCo
}
transaction AuthorizePayment {
--> Order order
--> Buyer buyer
--> FinanceCo financeCo
}
transaction Pay {
--> Order order
--> Seller seller
--> FinanceCo financeCo
}
transaction Refund {
o String refund
--> Order order
--> Seller seller
--> FinanceCo financeCo
}
来自供应商的订单输入abbykidfriendlyinccom1526916622207入境ID:bob@pchardwareinc.com,order.seller为:bob@pchardwareinc.com abbykidfriendlyinccom1526916622207 submitTransaction更新状态为Order From Supplier失败并显示文本:尝试调用业务网络时出错。错误:没有来自任何同行的有效回复。 来自尝试的对等通信的响应是错误:错误:2未知:执行链代码时出错:返回失败的事务:AccessException:参与者'org.acme.Z2BTestNetwork.Seller#bob@pchardwareinc.com'没有对资源的'CREATE'访问权限'org.acme.Z2BTestNetwork.OrderFromSupplier#751d9ec9d134be96cef201e495331f73aba55d004550c9b3d89bfc9f5cc225e5'
答案 0 :(得分:0)
错误表明你错过了一条规则 - 允许这些参与者使用交易类(资源) - 建议这样的事情 - 更高的规则列表' - 节点 - (不确定你的评论是否反映了此添加或不)
public TagModel() : base("name=TagModel")
{
Database.Log = x => Debug.WriteLine(x);
}
public virtual DbSet<Artikli> artiklis { get; set; }
public virtual DbSet<Permission> permissions { get; set; }
public virtual DbSet<Role> roles { get; set; }
public virtual DbSet<Tag> tags { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<Location> Locations { get; set; }
public virtual DbSet<Reader> Readers { get; set; }
public virtual DbSet<Order> Orders { get; set; }
public virtual DbSet<Antenna> Antennas { get; set; }
public virtual DbSet<Printer> Printers { get; set; }
public virtual DbSet<TagLocation> TagLocations { get; set; }
public virtual DbSet<LocationArticle> LocationArticles { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Artikli>()
.HasKey(e => e.Id)
.Property(e => e.klasa_artikla)
.IsFixedLength();
modelBuilder.Entity<Reader>()
.HasKey(reader => reader.Id)
.HasMany(reader => reader.Antennas)
.WithRequired(antenna => antenna.Reader)
.HasForeignKey(antenna => antenna.ReaderFK)
.WillCascadeOnDelete(true);
modelBuilder.Entity<Antenna>()
.HasKey(pk => new {
pk.Id,
pk.ReaderFK
});
modelBuilder.Entity<Location>()
.HasKey(e => e.Id)
.HasMany(e => e.Readers)
.WithRequired(reader => reader.Location)
.HasForeignKey(reader => reader.LocationFK);
modelBuilder.Entity<Location>()
.HasKey(e => e.Id)
.HasMany(e => e.Printers)
.WithRequired(printer => printer.Location)
.HasForeignKey(printer => printer.LocationFK);
/*modelBuilder.Entity<Location>()
.HasKey(e => e.Id)
.HasMany(e => e.Tags)
.WithMany(e => e.Locations)
.Map(m => m.ToTable("storage_tags", "public"));
*/
modelBuilder.Entity<Tag>()
.HasKey(e=> e.Id);
modelBuilder.Entity<LocationArticle>()
.HasKey(e => e.Id);
modelBuilder.Entity<LocationArticle>()
.HasRequired(e => e.Location)
.WithMany(t => t.LocationArticles)
.HasForeignKey(e => e.LocationFK);
modelBuilder.Entity<LocationArticle>()
.HasRequired(e => e.Article)
.WithMany(t => t.LocationArticles)
.HasForeignKey(e => e.ArticleFK);
modelBuilder.Entity<TagLocation>()
.HasKey(e => e.Id);
modelBuilder.Entity<TagLocation>()
.HasRequired(e => e.Tag)
.WithMany(t => t.Locations)
.HasForeignKey(e => e.TagFK);
modelBuilder.Entity<TagLocation>()
.HasRequired(e => e.LocationArticle)
.WithMany(t => t.TagLocations)
.HasForeignKey(e => e.LocationArticleFK);
modelBuilder.Entity<Printer>()
.HasKey(e => e.Id);
modelBuilder.Entity<Storage>().Map(m =>
{
m.ToTable("storages", "public");
});
modelBuilder.Entity<Shop>().Map(m =>
{
m.ToTable("shops", "public");
});
modelBuilder.Entity<Order>()
.HasKey(e => e.Id)
.HasRequired(e => e.Source)
.WithMany(location => location.SentOrders)
.HasForeignKey(e => e.SourceFK);
modelBuilder.Entity<Order>()
.HasKey(e => e.Id)
.HasRequired(e => e.Destination)
.WithMany(location => location.RecievedOrders)
.HasForeignKey(e => e.DestinationFK);
modelBuilder.Entity<OrderTag>()
.HasKey(pk => new { pk.OrderFK, pk.TagFK, pk.ArticleFK })
.HasRequired(ot => ot.OrderArticle)
.WithMany(oa => oa.OrderTags)
.HasForeignKey(fk => new { fk.OrderFK, fk.ArticleFK})
.WillCascadeOnDelete(true);
modelBuilder.Entity<OrderTag>()
.HasKey(pk => new { pk.OrderFK, pk.TagFK, pk.ArticleFK })
.HasRequired(ot => ot.Tag)
.WithMany(t => t.Orders)
.HasForeignKey(ot => ot.TagFK);
modelBuilder.Entity<OrderArticle>()
.HasKey(pk => new { pk.OrderFK, pk.ArticleFK })
.HasRequired(oa => oa.Article)
.WithMany(a => a.OrderArticles)
.HasForeignKey(oa => oa.ArticleFK);
modelBuilder.Entity<OrderArticle>()
.HasKey(pk => new { pk.OrderFK, pk.ArticleFK })
.HasRequired(oa => oa.Order)
.WithMany(o => o.Articles)
.HasForeignKey(oa => oa.OrderFK);
modelBuilder.Entity<Artikli>()
.HasKey(e => e.Id)
.HasMany(e => e.LocationArticles)
.WithRequired(e => e.Article)
.HasForeignKey(e => e.ArticleFK)
.WillCascadeOnDelete(false);
modelBuilder.Entity<Permission>()
.HasKey(e => e.Id)
.HasMany(e => e.roles)
.WithMany(e => e.Permissions)
.Map(m => m.ToTable("role_permission", "public"));
modelBuilder.Entity<User>()
.HasKey(e => e.Id)
.HasRequired(e => e.Location)
.WithMany(location => location.Users)
.HasForeignKey(e => e.LocationFK);
modelBuilder.Entity<Role>()
.HasKey(e => e.Id)
.HasMany(e => e.Users)
.WithMany(e => e.roles)
.Map(m =>
{
m.MapLeftKey("role_role_id");
m.MapRightKey("user_user_id");
m.ToTable("user_role", "public");
});
}
所以参与者有权执行该交易类型(上面的资源)。