public void CounterfeitArtefact(Artefact artefact) { Account.ForgetArtefact(artefact.Id); var counterfeit = new Artefact(artefact, Account.Id); OnCreatedArtefact(counterfeit); }
public void AddArtefact(Artefact artefact, AgentId ownerId) { if (!IsConnectedTo(ownerId)) { return; } var newArtefact = new Artefact(artefact, ownerId); GetPeer(ownerId).AddArtefact(newArtefact); RememberArtefact(newArtefact); }
public void AddArtefact(Artefact artefact) { if (HasArtefact(artefact.Id)) { throw new DuplicateKey <ArtefactId>(artefact.Id); } if (artefact.OwnerId != Id) { throw new ArgumentException("Cannot add artefact with othe owner"); } _artefacts.Add(artefact.Id, artefact); }
public void EndorceArtefact(Artefact artefact) { if (artefact.OwnerId == default) { throw new ArgumentException("Tried to endorce artefact without owner"); } var owner = ProducePeer(artefact.OwnerId); if (Account.KnowsArtefact(artefact.Id)) { artefact = Account.GetArtefact(artefact.Id); if (owner.Id != artefact.OwnerId) { throw new ArgumentException($"Tried to endorce artefact with invalid owner: {owner.Id}"); } } else { Account.RememberArtefact(artefact); } Account.IncreaseTrust(owner.Id, ArtefactEndorcementTrustFactor); OnEndorcedArtefact(artefact); }
public Artefact(Artefact artefact, AgentId ownerId) : this(artefact.Id, artefact.Name, ownerId) { }
public Artefact ProduceArtefact(Artefact artefact) => _knownArtefacts.TryGetValue(artefact.Id, out var knownArtefact) ? knownArtefact : new Artefact(artefact, default);
public void MoveArtefact(Artefact artefact, AgentId ownerId) { ForgetArtefact(artefact.Id); AddArtefact(artefact, ownerId); }
public void RememberArtefact(Artefact artefact) { _knownArtefacts.Add(artefact.Id, artefact); }
private bool VerifyArtefact(AgentId giver, Artefact transferedArtefact) => giver == transferedArtefact.OwnerId && (!Account.KnowsArtefact(transferedArtefact.Id) || Account.GetArtefact(transferedArtefact.Id).OwnerId == transferedArtefact.OwnerId);