Ejemplo n.º 1
0
// ArchiveBlockReferences implements the BlockServer interface for
// BlockServerRemote
func (b *BlockServerRemote) ArchiveBlockReferences(ctx context.Context,
	tlfID TlfID, contexts map[BlockID]BlockContext) error {
	refs := make([]keybase1.BlockReference, 0, len(contexts))
	for id, context := range contexts {
		refs = append(refs, keybase1.BlockReference{
			Bid: keybase1.BlockIdCombo{
				ChargedTo: context.GetCreator(),
				BlockHash: id.String(),
			},
			ChargedTo: context.GetWriter(),
			Nonce:     keybase1.BlockRefNonce(context.GetRefNonce()),
		})
	}
	return b.archiveBlockReferences(ctx, tlfID, refs)
}
Ejemplo n.º 2
0
// RemoveBlockReference implements the BlockServer interface for
// BlockServerRemote
func (b *BlockServerRemote) RemoveBlockReference(ctx context.Context, id BlockID,
	tlfID TlfID, context BlockContext) error {
	var err error
	defer func() {
		b.log.CDebugf(ctx, "RemoveBlockReference id=%s uid=%s err=%v",
			id, context.GetWriter(), err)
	}()

	ref := keybase1.BlockReference{
		Bid: keybase1.BlockIdCombo{
			ChargedTo: context.GetCreator(),
			BlockHash: id.String(),
		},
		ChargedTo: context.GetWriter(), //the actual writer to decrement quota from
		Nonce:     keybase1.BlockRefNonce(context.GetRefNonce()),
	}

	err = b.client.DelReference(ctx, keybase1.DelReferenceArg{
		Ref:    ref,
		Folder: tlfID.String(),
	})
	return err
}