Published: 21 Mar 2018 › Updated: 21 Mar 2018
clayop님의 개발 요청에 도움이 될까 싶어 올립니다.
님의 어뷰징 감지를 위한 개발을 요청드립니다 에 대한 포스트입니다.
제가 전부 완성할 능력은 없고, steem-python의 테두리 내에서 도움이 될까 싶어 올립니다.
GitHub로 공유드리고 싶지만... 아직 안만들어서 그냥 포스트로 올립니다.
- kr 유저를 구분해야하는지에 대한 내용이 본문에 없었고
- 만약 그러하다면 whitelist를 만들어야하며
- 유저명을 implicit suffix tree로 따로 저장하고
- 매 번 모든 유저를 검색해야하는지, 상위 100명 정도를 후보군으로 만들고 마크를 하면서 후보군 갱신은 주 또는 월단위가 좋을 것 같다는 생각입니다.
실행 시 결과는 그림처럼 나옵니다.
from steem import Steem
from steem.steem import Steem
from steem.account import Account
from steem.converter import Converter
from dateutil.parser import parse
from datetime import datetime, timedelta
import re
s = Steem(nodes=["https://api.steemit.com"])
converter = Converter(steemd_instance=s)
def diff_in_seconds(vtime):
return (datetime.utcnow() - parse(vtime)).total_seconds()
# 계정명
acc_name = 'whoami'
print('계정명 : ', acc_name)
# 계정 정보
acc_info = s.get_account(acc_name)
# 계정 보유 SP (acc_sp)
acc_svs = float(re.findall("([0-9]+(?:\.[0-9]+)?)(?:\s)", acc_info['vesting_shares'])[0])
acc_dvs = float(re.findall("([0-9]+(?:\.[0-9]+)?)(?:\s)", acc_info['delegated_vesting_shares'])[0])
acc_rvs = float(re.findall("([0-9]+(?:\.[0-9]+)?)(?:\s)", acc_info['received_vesting_shares'])[0])
acc_vs = acc_svs + acc_rvs - acc_dvs
acc_sp = round(converter.vests_to_sp(acc_vs))
print('보유 스파 : ', acc_sp)
# 보팅한 목록
acc_given_votes = s.get_account_votes(acc_name)
# 기간 설정
days = 14
acc_vote_info = [ vote for vote in acc_given_votes
if diff_in_seconds(vote['time']) < (days * 86400) ]
print('기간 : ', days)
# 총 voting weight, rshares 및 셀프 rshares
all_vweight = 0
all_rshares = 0
self_rshares = 0
for v in acc_vote_info:
all_vweight += float(v['percent'])
all_rshares += float(v['rshares'])
if v['authorperm'].split("/")[0] == acc_name:
self_rshares += float(v['rshares'])
print('기간 내 총 rshares : ', all_rshares)
print('기간 내 총 Voting Weight : ', all_vweight)
# 셀프 보팅 비율
print( '셀프보팅 비율 : %.3f' % (self_rshares / all_rshares) )
# 기간 내 Inverse Simpson
vtarget = dict()
## 인원별 보팅횟수와 rshares의 총합
for vote in acc_vote_info:
name = vote['authorperm'].split("/")[0]
if name not in vtarget:
vtarget[name] = {'count':0, 'sum_of_rshares':0}
vtarget[name]['count'] += 1
vtarget[name]['sum_of_rshares'] += float(vote['rshares'])
# Inverse Simpson 값
sum_of_percent = 0
sum_of_percent_square = 0
for v in vtarget:
sum_of_percent_square += (vtarget[v]['sum_of_rshares'] / float(all_rshares)) ** 2
Inverse_Simpson = 1.0 / float(sum_of_percent_square)
print( 'Inverse Simpson(rshare) : %.3f' % Inverse_Simpson)
Leave clayop님의 개발 요청에 도움이 될까 싶어 올립니다. to:
Read more #kr posts
Best Posts From 마아냐(@maanya)
We have not curated any of maanya's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From 마아냐(@maanya)
- 근황 보고
- 나의 삼십오 퍼센트 - 2
- 그냥 일기
- 나의 삼십오 퍼센트 - 1
- [코딩몰라여] steem-python으로 방문자를 위한 봇 만들기 편
- 올리브콘 코엑스 C홀 C-06 스팀아트 클라우드
- 봄사월 이십팔일
- [코딩몰라여] steem-python으로 포스트와 댓글 실시간으로 읽어오기 기초 ~속도개선~ 편
- [코딩몰라여] steem-python으로 포스트와 댓글 실시간으로 읽어오기 기초 ~예외처리~ 편
- [코딩몰라여] steem-python으로 포스트와 댓글 실시간으로 읽어오기 기초
- 억울함.
- @maanya 닉네임 챌린지이이ㅣㅣ다냐-
- 반말 일기
- [코딩몰라여] steem-python 쉬어가는편! 마아냐 웹페이지 소개 등등.
- @zzoya's ecobag. 쪼코백, 도착.
- 술과 함께 걸어온 시간
- Inverse Simpson에 대한 잉여로운 고찰
- [코딩몰라여] steem-python으로 내가 받은 모든 보상 확인하기
- 쿨타임이 차서 쓰는 번호일기
- clayop님의 개발 요청에 도움이 될까 싶어 올립니다.